diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2017-01-11 22:35:36 +0200 |
---|---|---|
committer | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2017-01-20 17:37:58 +0000 |
commit | 0371486a32a0e39cdc9d04f9d1245b214d269e3c (patch) | |
tree | 9d107e6ce72903687b7d7bea21d784bc322b16e0 /src | |
parent | 9bf05a32a155566e8f3ff30651b410b5b4822f71 (diff) |
Fix incorrect text highlight in OpenWnnInputMethod
Wrong length was given for the remainder highlight attribute,
which caused the highlight to overflow.
Steps to reproduce:
1. [English] type abcdefgh and move cursor to middle of text abcd|efgh
2. [Japanese] enter word "hiragana"
3. [Japanese] press left arrow ←
Observed result:
Pre-edit text highlight (light blue) exceeds the pre-edit text.
Expected result:
Pre-edit text highlight should not exceed the pre-edit text.
Change-Id: I66002357e2fc008ccdd6f89db8baaab64f9d5070
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/virtualkeyboard/openwnninputmethod.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/virtualkeyboard/openwnninputmethod.cpp b/src/virtualkeyboard/openwnninputmethod.cpp index cb5a88f9..38812f97 100644 --- a/src/virtualkeyboard/openwnninputmethod.cpp +++ b/src/virtualkeyboard/openwnninputmethod.cpp @@ -235,12 +235,12 @@ public: attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, highlightEnd, textFormat)); } - if (highlightEnd != 0) { + if (highlightEnd != 0 && highlightEnd < displayText.length()) { /* highlights remaining text */ QTextCharFormat textFormat; textFormat.setBackground(QBrush(QColor(0xF0, 0xFF, 0xFF))); textFormat.setForeground(QBrush(Qt::black)); - attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, highlightEnd, composingText.toString(layer).length(), textFormat)); + attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, highlightEnd, displayText.length() - highlightEnd, textFormat)); } } |