diff options
author | nyamatongwe <nyamatongwe@gmail.com> | 2013-04-17 14:37:29 +1000 |
---|---|---|
committer | nyamatongwe <nyamatongwe@gmail.com> | 2013-04-17 14:37:29 +1000 |
commit | 3b5d6373239e7a35d172c359dab3c4138f6f9b68 (patch) | |
tree | d05a4356d80e36299ba8f80b2745bc1289268032 | |
parent | 8f5bc219c07a66c01f351901109d7bac2d602bd9 (diff) | |
download | scintilla-mirror-3b5d6373239e7a35d172c359dab3c4138f6f9b68.tar.gz |
When switching documents, reset input composition as otherwise get mixture of state
from both documents.
-rw-r--r-- | cocoa/ScintillaCocoa.h | 1 | ||||
-rw-r--r-- | cocoa/ScintillaCocoa.mm | 15 | ||||
-rw-r--r-- | src/Editor.h | 2 |
3 files changed, 17 insertions, 1 deletions
diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h index 5aaa386d2..7648b84d8 100644 --- a/cocoa/ScintillaCocoa.h +++ b/cocoa/ScintillaCocoa.h @@ -199,6 +199,7 @@ public: virtual void QueueIdleWork(WorkNeeded::workItems items, int upTo); int InsertText(NSString* input); void SelectOnlyMainSelection(); + virtual void SetDocPointer(Document *document); bool KeyboardInput(NSEvent* event); void MouseDown(NSEvent* event); diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index dfe2e47d1..d8dd6ae7b 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -1930,6 +1930,21 @@ void ScintillaCocoa::SelectOnlyMainSelection() } //-------------------------------------------------------------------------------------------------- +/** + * When switching documents discard any incomplete character composition state as otherwise tries to + * act on the new document. + */ +void ScintillaCocoa::SetDocPointer(Document *document) +{ + // Drop input composition. + NSTextInputContext *inctxt = [NSTextInputContext currentInputContext]; + [inctxt discardMarkedText]; + InnerView *inner = ContentView(); + [inner removeMarkedText]; + Editor::SetDocPointer(document); +} + +//-------------------------------------------------------------------------------------------------- /** * Called by the owning view when the mouse pointer enters the control. diff --git a/src/Editor.h b/src/Editor.h index f2b452a77..4e6c7aee9 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -565,7 +565,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void SetBraceHighlight(Position pos0, Position pos1, int matchStyle); void SetAnnotationHeights(int start, int end); - void SetDocPointer(Document *document); + virtual void SetDocPointer(Document *document); void SetAnnotationVisible(int visible); |