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 | c4279c0a62777aceac64fd37d366e257f13d3528 (patch) | |
| tree | 8cc4c377fe2aa7620b8f91d072b5985dc59d81f6 | |
| parent | 6af21a0ecb134a6cdeb1e9083b5c5064b5351bff (diff) | |
| download | scintilla-mirror-c4279c0a62777aceac64fd37d366e257f13d3528.tar.gz | |
When setting composition text, correctly select the indicated text by converting range to bytes.
| -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];    }  }  | 
