From d7e2afd1f88bf735b010461ff505470bfa468547 Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Sun, 30 Jun 2019 08:34:46 +1000 Subject: Bug [#2038]. Source of input reported in SCN_CHARADDED. This may be SC_CHARACTERSOURCE_DIRECT_INPUT, SC_CHARACTERSOURCE_TENTATIVE_INPUT, or SC_CHARACTERSOURCE_IME_RESULT. --- src/Editor.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/Editor.cxx') diff --git a/src/Editor.cxx b/src/Editor.cxx index 92c77571e..2cf12f61f 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1891,7 +1891,7 @@ void Editor::AddChar(char ch) { char s[2]; s[0] = ch; s[1] = '\0'; - InsertCharacter(std::string_view(s, 1)); + InsertCharacter(std::string_view(s, 1), CharacterSource::directInput); } void Editor::FilterSelections() { @@ -1902,7 +1902,7 @@ void Editor::FilterSelections() { } // InsertCharacter inserts a character encoded in document code page. -void Editor::InsertCharacter(std::string_view sv) { +void Editor::InsertCharacter(std::string_view sv, CharacterSource charSource) { if (sv.empty()) { return; } @@ -1994,9 +1994,9 @@ void Editor::InsertCharacter(std::string_view sv) { ch = utf32[0]; } } - NotifyChar(ch); + NotifyChar(ch, charSource); - if (recordingMacro) { + if (recordingMacro && charSource != CharacterSource::tentativeInput) { std::string copy(sv); // ensure NUL-terminated NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast(copy.data())); } @@ -2342,10 +2342,11 @@ void Editor::NotifyErrorOccurred(Document *, void *, int status) { errorStatus = status; } -void Editor::NotifyChar(int ch) { +void Editor::NotifyChar(int ch, CharacterSource charSource) { SCNotification scn = {}; scn.nmhdr.code = SCN_CHARADDED; scn.ch = ch; + scn.characterSource = static_cast(charSource); NotifyParent(scn); } @@ -3091,7 +3092,7 @@ void Editor::NewLine() { for (size_t i = 0; i < countInsertions; i++) { const char *eol = StringFromEOLMode(pdoc->eolMode); while (*eol) { - NotifyChar(*eol); + NotifyChar(*eol, CharacterSource::directInput); if (recordingMacro) { char txt[2]; txt[0] = *eol; -- cgit v1.2.3