Merge lp:~michael-sheldon/ubuntu-keyboard/fix-1375951 into lp:ubuntu-keyboard
- fix-1375951
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Bill Filler |
Approved revision: | 236 |
Merged at revision: | 232 |
Proposed branch: | lp:~michael-sheldon/ubuntu-keyboard/fix-1375951 |
Merge into: | lp:ubuntu-keyboard |
Diff against target: |
190 lines (+40/-22) 4 files modified
qml/keys/CharKey.qml (+3/-2) src/plugin/inputmethod.cpp (+9/-9) src/plugin/inputmethod.h (+1/-1) src/view/abstracttexteditor.cpp (+27/-10) |
To merge this branch: | bzr merge lp:~michael-sheldon/ubuntu-keyboard/fix-1375951 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Bill Filler (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+237458@code.launchpad.net |
Commit message
Fix re-entry of preedit when in the middle of a sentence, disable preedit when editing in the middle of a word and re-evaluate autocaps whenever the cursor position changes.
Description of the change
Fix re-entry of preedit when in the middle of a sentence, disable preedit when editing in the middle of a word and re-evaluate autocaps whenever the cursor position changes.
Michael Sheldon (michael-sheldon) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:233
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Bill Filler (bfiller) wrote : | # |
Works quite well except for one issue. If you move the cursor to the end of a word and start backspacing, predit gets correctly enabled and shows word choices. The problem is when you select one (or press the space) bar, an additional space gets inserted after the word, leaving you with a double space.
Example:
"Hello brother and sister."
move cursor to end of brother
start backspacing until only "bro" is left. Then type a "t". Now select "brother" from word ribbon and you are left with:
"Hello brother and sister."
I think the fix would be to only auto insert the space if you detect we are at end of the line if that is possible?
- 234. By Michael Sheldon
-
Only insert spaces on autocomplete if we're not in the middle of a sentence
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:234
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 235. By Michael Sheldon
-
Return space behaviour to normal if the user continues typing after editing a word in the middle of a sentence.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:235
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 236. By Michael Sheldon
-
Don't insert spaces when editing words in the middle of sentences from word ribbon selection
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:236
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Bill Filler (bfiller) wrote : | # |
tested, all issues fixed
Preview Diff
1 | === modified file 'qml/keys/CharKey.qml' | |||
2 | --- qml/keys/CharKey.qml 2014-09-26 17:41:47 +0000 | |||
3 | +++ qml/keys/CharKey.qml 2014-10-10 13:28:23 +0000 | |||
4 | @@ -206,8 +206,8 @@ | |||
5 | 206 | extendedKeysSelector.closePopover(); | 206 | extendedKeysSelector.closePopover(); |
6 | 207 | } | 207 | } |
7 | 208 | } else if(!swipedOut) { | 208 | } else if(!swipedOut) { |
10 | 209 | event_handler.onKeyReleased(valueToSubmit, action); | 209 | // Read this prior to altering autocaps |
11 | 210 | 210 | var keyToSend = valueToSubmit; | |
12 | 211 | if (magnifier.currentlyAssignedKey == key) { | 211 | if (magnifier.currentlyAssignedKey == key) { |
13 | 212 | magnifier.shown = false; | 212 | magnifier.shown = false; |
14 | 213 | } | 213 | } |
15 | @@ -222,6 +222,7 @@ | |||
16 | 222 | if (switchBackFromSymbols && panel.state === "SYMBOLS") { | 222 | if (switchBackFromSymbols && panel.state === "SYMBOLS") { |
17 | 223 | panel.state = "CHARACTERS"; | 223 | panel.state = "CHARACTERS"; |
18 | 224 | } | 224 | } |
19 | 225 | event_handler.onKeyReleased(keyToSend, action); | ||
20 | 225 | } | 226 | } |
21 | 226 | } | 227 | } |
22 | 227 | 228 | ||
23 | 228 | 229 | ||
24 | === modified file 'src/plugin/inputmethod.cpp' | |||
25 | --- src/plugin/inputmethod.cpp 2014-09-25 13:44:09 +0000 | |||
26 | +++ src/plugin/inputmethod.cpp 2014-10-10 13:28:23 +0000 | |||
27 | @@ -370,7 +370,7 @@ | |||
28 | 370 | d->editor.text()->setSurroundingOffset(position); | 370 | d->editor.text()->setSurroundingOffset(position); |
29 | 371 | 371 | ||
30 | 372 | updateAutoCaps(); | 372 | updateAutoCaps(); |
32 | 373 | checkInitialAutocaps(); | 373 | checkAutocaps(); |
33 | 374 | d->previous_position = position; | 374 | d->previous_position = position; |
34 | 375 | } | 375 | } |
35 | 376 | } | 376 | } |
36 | @@ -412,9 +412,9 @@ | |||
37 | 412 | updateAutoCaps(); | 412 | updateAutoCaps(); |
38 | 413 | } | 413 | } |
39 | 414 | 414 | ||
43 | 415 | //! \brief InputMethod::checkInitialAutocaps Checks if the keyboard should be | 415 | //! \brief InputMethod::checkAutocaps Checks if the keyboard should be |
44 | 416 | //! set to uppercase, because the auto caps is enabled and the text is empty. | 416 | //! set to uppercase after the cursor position has been changed. |
45 | 417 | void InputMethod::checkInitialAutocaps() | 417 | void InputMethod::checkAutocaps() |
46 | 418 | { | 418 | { |
47 | 419 | Q_D(InputMethod); | 419 | Q_D(InputMethod); |
48 | 420 | 420 | ||
49 | @@ -422,12 +422,12 @@ | |||
50 | 422 | QString text; | 422 | QString text; |
51 | 423 | int position; | 423 | int position; |
52 | 424 | bool ok = d->host->surroundingText(text, position); | 424 | bool ok = d->host->surroundingText(text, position); |
55 | 425 | QString textOnLeft = (d->editor.text()->surroundingLeft() + d->editor.text()->preedit()).trimmed(); | 425 | QString textOnLeft = d->editor.text()->surroundingLeft() + d->editor.text()->preedit(); |
56 | 426 | if (ok && text.isEmpty() && d->editor.text()->preedit().isEmpty() && position == 0) { | 426 | if (ok && ((text.isEmpty() && d->editor.text()->preedit().isEmpty() && position == 0) |
57 | 427 | || d->editor.wordEngine()->languageFeature()->activateAutoCaps(textOnLeft) | ||
58 | 428 | || d->editor.wordEngine()->languageFeature()->activateAutoCaps(textOnLeft.trimmed()))) { | ||
59 | 427 | Q_EMIT activateAutocaps(); | 429 | Q_EMIT activateAutocaps(); |
63 | 428 | } else if (!d->editor.wordEngine()->languageFeature()->activateAutoCaps(textOnLeft)) { | 430 | } else { |
61 | 429 | // Clear autocaps if it has been set by us previously being in an | ||
62 | 430 | // empty field | ||
64 | 431 | Q_EMIT deactivateAutocaps(); | 431 | Q_EMIT deactivateAutocaps(); |
65 | 432 | } | 432 | } |
66 | 433 | } | 433 | } |
67 | 434 | 434 | ||
68 | === modified file 'src/plugin/inputmethod.h' | |||
69 | --- src/plugin/inputmethod.h 2014-09-10 14:57:52 +0000 | |||
70 | +++ src/plugin/inputmethod.h 2014-10-10 13:28:23 +0000 | |||
71 | @@ -147,7 +147,7 @@ | |||
72 | 147 | Q_SLOT void onLayoutWidthChanged(int width); | 147 | Q_SLOT void onLayoutWidthChanged(int width); |
73 | 148 | Q_SLOT void onLayoutHeightChanged(int height); | 148 | Q_SLOT void onLayoutHeightChanged(int height); |
74 | 149 | 149 | ||
76 | 150 | void checkInitialAutocaps(); | 150 | void checkAutocaps(); |
77 | 151 | 151 | ||
78 | 152 | const QScopedPointer<InputMethodPrivate> d_ptr; | 152 | const QScopedPointer<InputMethodPrivate> d_ptr; |
79 | 153 | }; | 153 | }; |
80 | 154 | 154 | ||
81 | === modified file 'src/view/abstracttexteditor.cpp' | |||
82 | --- src/view/abstracttexteditor.cpp 2014-09-25 15:18:42 +0000 | |||
83 | +++ src/view/abstracttexteditor.cpp 2014-10-10 13:28:23 +0000 | |||
84 | @@ -287,6 +287,7 @@ | |||
85 | 287 | QString ignore_next_surrounding_text; | 287 | QString ignore_next_surrounding_text; |
86 | 288 | bool look_for_a_double_space; | 288 | bool look_for_a_double_space; |
87 | 289 | bool double_space_full_stop_enabled; | 289 | bool double_space_full_stop_enabled; |
88 | 290 | bool editing_middle_of_text; | ||
89 | 290 | QString appendix_for_previous_preedit; | 291 | QString appendix_for_previous_preedit; |
90 | 291 | int backspace_word_acceleration; | 292 | int backspace_word_acceleration; |
91 | 292 | QString keyboardState; | 293 | QString keyboardState; |
92 | @@ -313,6 +314,7 @@ | |||
93 | 313 | , ignore_next_surrounding_text() | 314 | , ignore_next_surrounding_text() |
94 | 314 | , look_for_a_double_space(false) | 315 | , look_for_a_double_space(false) |
95 | 315 | , double_space_full_stop_enabled(false) | 316 | , double_space_full_stop_enabled(false) |
96 | 317 | , editing_middle_of_text(false) | ||
97 | 316 | , appendix_for_previous_preedit() | 318 | , appendix_for_previous_preedit() |
98 | 317 | , backspace_word_acceleration(0) | 319 | , backspace_word_acceleration(0) |
99 | 318 | , keyboardState("CHARACTERS") | 320 | , keyboardState("CHARACTERS") |
100 | @@ -443,7 +445,12 @@ | |||
101 | 443 | not d->text->preedit().isEmpty() && isSeparator; | 445 | not d->text->preedit().isEmpty() && isSeparator; |
102 | 444 | 446 | ||
103 | 445 | if (d->preedit_enabled) { | 447 | if (d->preedit_enabled) { |
105 | 446 | if (replace_preedit) { | 448 | if (d->text->surroundingRight().left(1).contains(QRegExp("[\\w]"))) { |
106 | 449 | // We're editing in the middle of a word, so just insert characters directly | ||
107 | 450 | d->text->appendToPreedit(text); | ||
108 | 451 | commitPreedit(); | ||
109 | 452 | alreadyAppended = true; | ||
110 | 453 | } else if (replace_preedit) { | ||
111 | 447 | // this means we should commit the candidate, add the separator and whitespace | 454 | // this means we should commit the candidate, add the separator and whitespace |
112 | 448 | d->text->setPreedit(d->text->primaryCandidate()); | 455 | d->text->setPreedit(d->text->primaryCandidate()); |
113 | 449 | d->text->appendToPreedit(text); | 456 | d->text->appendToPreedit(text); |
114 | @@ -510,6 +517,7 @@ | |||
115 | 510 | case Key::ActionSpace: { | 517 | case Key::ActionSpace: { |
116 | 511 | QString space = " "; | 518 | QString space = " "; |
117 | 512 | QString textOnLeft = d->text->surroundingLeft() + d->text->preedit(); | 519 | QString textOnLeft = d->text->surroundingLeft() + d->text->preedit(); |
118 | 520 | QString textOnRight = d->text->surroundingRight().trimmed(); | ||
119 | 513 | bool auto_caps_activated = d->word_engine->languageFeature()->activateAutoCaps(textOnLeft); | 521 | bool auto_caps_activated = d->word_engine->languageFeature()->activateAutoCaps(textOnLeft); |
120 | 514 | const bool replace_preedit = d->auto_correct_enabled && not d->text->primaryCandidate().isEmpty() && not d->text->preedit().isEmpty(); | 522 | const bool replace_preedit = d->auto_correct_enabled && not d->text->primaryCandidate().isEmpty() && not d->text->preedit().isEmpty(); |
121 | 515 | const QString stopSequence = d->word_engine->languageFeature()->fullStopSequence(); | 523 | const QString stopSequence = d->word_engine->languageFeature()->fullStopSequence(); |
122 | @@ -520,7 +528,14 @@ | |||
123 | 520 | } | 528 | } |
124 | 521 | 529 | ||
125 | 522 | if (replace_preedit) { | 530 | if (replace_preedit) { |
127 | 523 | space = d->appendix_for_previous_preedit = d->word_engine->languageFeature()->appendixForReplacedPreedit(d->text->preedit()); | 531 | if (!textOnRight.isEmpty() && d->editing_middle_of_text) { |
128 | 532 | // Don't insert a space if we are correcting a word in the middle of a sentence | ||
129 | 533 | space = ""; | ||
130 | 534 | d->look_for_a_double_space = false; | ||
131 | 535 | d->editing_middle_of_text = false; | ||
132 | 536 | } else { | ||
133 | 537 | space = d->appendix_for_previous_preedit = d->word_engine->languageFeature()->appendixForReplacedPreedit(d->text->preedit()); | ||
134 | 538 | } | ||
135 | 524 | d->text->setPreedit(d->text->primaryCandidate()); | 539 | d->text->setPreedit(d->text->primaryCandidate()); |
136 | 525 | } | 540 | } |
137 | 526 | else if (look_for_a_double_space && not stopSequence.isEmpty()) { | 541 | else if (look_for_a_double_space && not stopSequence.isEmpty()) { |
138 | @@ -543,10 +558,6 @@ | |||
139 | 543 | case Key::ActionReturn: { | 558 | case Key::ActionReturn: { |
140 | 544 | event_key = Qt::Key_Return; | 559 | event_key = Qt::Key_Return; |
141 | 545 | keyText = QString("\r"); | 560 | keyText = QString("\r"); |
142 | 546 | |||
143 | 547 | if (d->word_engine->languageFeature()->activateAutoCaps(keyText) && d->auto_caps_enabled) { | ||
144 | 548 | Q_EMIT autoCapsActivated(); | ||
145 | 549 | } | ||
146 | 550 | } break; | 561 | } break; |
147 | 551 | 562 | ||
148 | 552 | case Key::ActionClose: | 563 | case Key::ActionClose: |
149 | @@ -672,6 +683,11 @@ | |||
150 | 672 | const bool auto_caps_activated = d->word_engine->languageFeature()->activateAutoCaps(d->text->preedit()); | 683 | const bool auto_caps_activated = d->word_engine->languageFeature()->activateAutoCaps(d->text->preedit()); |
151 | 673 | d->appendix_for_previous_preedit = d->word_engine->languageFeature()->appendixForReplacedPreedit(d->text->preedit()); | 684 | d->appendix_for_previous_preedit = d->word_engine->languageFeature()->appendixForReplacedPreedit(d->text->preedit()); |
152 | 674 | if (d->auto_correct_enabled) { | 685 | if (d->auto_correct_enabled) { |
153 | 686 | if (!d->text->surroundingRight().trimmed().isEmpty() && d->editing_middle_of_text) { | ||
154 | 687 | // Don't insert a space if we are correcting a word in the middle of a sentence | ||
155 | 688 | d->appendix_for_previous_preedit = ""; | ||
156 | 689 | d->editing_middle_of_text = false; | ||
157 | 690 | } | ||
158 | 675 | d->text->appendToPreedit(d->appendix_for_previous_preedit); | 691 | d->text->appendToPreedit(d->appendix_for_previous_preedit); |
159 | 676 | } | 692 | } |
160 | 677 | commitPreedit(); | 693 | commitPreedit(); |
161 | @@ -943,6 +959,9 @@ | |||
162 | 943 | } | 959 | } |
163 | 944 | } | 960 | } |
164 | 945 | 961 | ||
165 | 962 | if(!d->text->surroundingRight().trimmed().isEmpty()) { | ||
166 | 963 | d->editing_middle_of_text = true; | ||
167 | 964 | } | ||
168 | 946 | d->backspace_sent = true; | 965 | d->backspace_sent = true; |
169 | 947 | } | 966 | } |
170 | 948 | 967 | ||
171 | @@ -1052,8 +1071,8 @@ | |||
172 | 1052 | leftWords.removeLast(); | 1071 | leftWords.removeLast(); |
173 | 1053 | trimDiff += 1; | 1072 | trimDiff += 1; |
174 | 1054 | } | 1073 | } |
177 | 1055 | if(!text()->surroundingRight().trimmed().isEmpty()) { | 1074 | if(d->text->surroundingRight().left(1).contains(QRegExp("[\\w]"))) { |
178 | 1056 | // We don't currently handle reentering preedit in the middle of the text | 1075 | // Don't enter pre-edit in the middle of a word |
179 | 1057 | return; | 1076 | return; |
180 | 1058 | } | 1077 | } |
181 | 1059 | QString recreatedPreedit = leftWords.last(); | 1078 | QString recreatedPreedit = leftWords.last(); |
182 | @@ -1062,8 +1081,6 @@ | |||
183 | 1062 | // as the last backspace hasn't been committed yet. | 1081 | // as the last backspace hasn't been committed yet. |
184 | 1063 | recreatedPreedit.chop(1); | 1082 | recreatedPreedit.chop(1); |
185 | 1064 | } | 1083 | } |
186 | 1065 | int position = currentOffset - recreatedPreedit.size(); | ||
187 | 1066 | QString surroundWithoutPreedit = text()->surrounding().remove(position, recreatedPreedit.size()); | ||
188 | 1067 | 1084 | ||
189 | 1068 | for(int i = 0; i < recreatedPreedit.size(); i++) { | 1085 | for(int i = 0; i < recreatedPreedit.size(); i++) { |
190 | 1069 | singleBackspace(); | 1086 | singleBackspace(); |
Are there any related MPs required for this MP to build/function as expected? Please list.
* No
Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
* Yes
Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
* Yes
Did you successfully run all tests found in your component's Test Plan (https:/ /wiki.ubuntu. com/Process/ Merges/ TestPlan/ ubuntu- keyboard) on device or emulator?
* Yes
If you changed the UI, was the change specified/approved by design?
* No change
If you changed UI labels, did you update the pot file?
* No change
If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?
* No change