diff options
author | nyamatongwe <nyamatongwe@gmail.com> | 2013-04-17 10:52:59 +1000 |
---|---|---|
committer | nyamatongwe <nyamatongwe@gmail.com> | 2013-04-17 10:52:59 +1000 |
commit | e69cb8f6878b1b3e8ffbcbf9ef139976998254f0 (patch) | |
tree | 4b9d341346e4fcceeac50246bb01314dfb5a8acd /cocoa/ScintillaView.mm | |
parent | f17c785c236648e3370efc1006b81f2b73946ce0 (diff) | |
download | scintilla-mirror-e69cb8f6878b1b3e8ffbcbf9ef139976998254f0.tar.gz |
When setting composition text, correctly select the indicated text by converting range to bytes.
Diffstat (limited to 'cocoa/ScintillaView.mm')
-rw-r--r-- | cocoa/ScintillaView.mm | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index 48ccdf1ef..4fa6dcb54 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -437,10 +437,14 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) // Select the part which is indicated in the given range. It does not scroll the caret into view. if (range.length > 0) { - [mOwner setGeneralProperty: SCI_SETSELECTIONSTART - value: currentPosition + range.location]; - [mOwner setGeneralProperty: SCI_SETSELECTIONEND - value: currentPosition + range.location + range.length]; + // range is in characters so convert to bytes for selection. + int rangeStart = currentPosition; + for (size_t characterInComposition=0; characterInComposition<range.location; characterInComposition++) + rangeStart = [mOwner getGeneralProperty: SCI_POSITIONAFTER parameter: rangeStart]; + int rangeEnd = rangeStart; + for (size_t characterInRange=0; characterInRange<range.length; characterInRange++) + rangeEnd = [mOwner getGeneralProperty: SCI_POSITIONAFTER parameter: rangeEnd]; + [mOwner setGeneralProperty: SCI_SETSELECTION parameter: rangeEnd value: rangeStart]; } } |