From 553a78b81d0deeb96940a7486074364e75d50068 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Tue, 9 Apr 2013 13:15:47 +1000 Subject: Fix problems with input composition that could stop undo working. --- cocoa/ScintillaCocoa.h | 3 ++- cocoa/ScintillaCocoa.mm | 15 +++++++++++++++ cocoa/ScintillaView.mm | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'cocoa') diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h index 0c0448118..5aaa386d2 100644 --- a/cocoa/ScintillaCocoa.h +++ b/cocoa/ScintillaCocoa.h @@ -198,7 +198,8 @@ public: virtual void IdleWork(); virtual void QueueIdleWork(WorkNeeded::workItems items, int upTo); int InsertText(NSString* input); - + void SelectOnlyMainSelection(); + bool KeyboardInput(NSEvent* event); void MouseDown(NSEvent* event); void MouseMove(NSEvent* event); diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index e348488ff..dfe2e47d1 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -1916,6 +1916,21 @@ int ScintillaCocoa::InsertText(NSString* input) //-------------------------------------------------------------------------------------------------- +/** + * Used to ensure that only one selection is active for input composition as composition + * does not support multi-typing. + * Also drop virtual space as that is not supported by composition. + */ +void ScintillaCocoa::SelectOnlyMainSelection() +{ + SelectionRange mainSel = sel.RangeMain(); + mainSel.ClearVirtualSpace(); + sel.SetSelection(mainSel); + Redraw(); +} + +//-------------------------------------------------------------------------------------------------- + /** * Called by the owning view when the mouse pointer enters the control. */ diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index f9496cac1..48ccdf1ef 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -401,6 +401,11 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) value: mMarkedTextRange.location + mMarkedTextRange.length]; currentPosition = mMarkedTextRange.location; } + else + { + // Ensure only a single selection + mOwner.backend->SelectOnlyMainSelection(); + } // Keep Scintilla from collecting undo actions for the composition task. undoCollectionWasActive = [mOwner getGeneralProperty: SCI_GETUNDOCOLLECTION] != 0; -- cgit v1.2.3