Merge lp:~michael-sheldon/ubuntu-keyboard/fix-1579083 into lp:ubuntu-keyboard

Proposed by Michael Sheldon
Status: Merged
Approved by: Bill Filler
Approved revision: 481
Merged at revision: 507
Proposed branch: lp:~michael-sheldon/ubuntu-keyboard/fix-1579083
Merge into: lp:ubuntu-keyboard
Diff against target: 153 lines (+43/-6)
5 files modified
plugins/chewing/src/chewinglanguagefeatures.cpp (+1/-1)
plugins/pinyin/src/chineselanguagefeatures.cpp (+1/-1)
plugins/westernsupport/westernlanguagefeatures.cpp (+1/-1)
src/view/abstracttexteditor.cpp (+29/-2)
tests/unittests/ut_editor/ut_editor.cpp (+11/-1)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-keyboard/fix-1579083
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+302925@code.launchpad.net

Commit message

Improve double space punctuation insertion behaviour

Description of the change

Improve double space punctuation insertion behaviour

To post a comment you must log in.
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:478
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-keyboard-ci/30/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1189/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1189
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1069
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1069
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1069
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1057
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1057/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1057
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1057/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1057/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1057
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1057/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1057
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1057/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1057/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1057
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1057/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1057
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1057/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1057/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-keyboard-ci/30/rebuild

review: Needs Fixing (continuous-integration)
479. By Michael Sheldon

Remove automatically inserted full-stop if the user continues to insert space characters after a double space

480. By Michael Sheldon

Add unit tests for improved punctuation behaviour

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:480
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-keyboard-ci/33/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1224/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1224
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1098
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1098
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1098
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1085
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1085/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1085
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1085/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1085/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1085
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1085/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1085
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1085/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1085/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1085
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1085/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1085
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1085/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1085/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-keyboard-ci/33/rebuild

review: Needs Fixing (continuous-integration)
481. By Michael Sheldon

Add comment on usage of triple space detection

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:481
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-keyboard-ci/36/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1241/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1241
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1114
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1114
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1114
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1101
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1101/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1101
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1101/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1101/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1101
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1101/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1101
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1101/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1101/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1101
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1101/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1101
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1101/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1101/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-keyboard-ci/36/rebuild

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/chewing/src/chewinglanguagefeatures.cpp'
--- plugins/chewing/src/chewinglanguagefeatures.cpp 2016-04-28 12:15:46 +0000
+++ plugins/chewing/src/chewinglanguagefeatures.cpp 2016-08-18 13:50:50 +0000
@@ -55,7 +55,7 @@
5555
56bool ChewingLanguageFeatures::isSeparator(const QString &text) const56bool ChewingLanguageFeatures::isSeparator(const QString &text) const
57{57{
58 static const QString separators = QString::fromUtf8("。、!?:\r\n");58 static const QString separators = QString::fromUtf8("。、!?:…\r\n");
5959
60 if (text.isEmpty()) {60 if (text.isEmpty()) {
61 return false;61 return false;
6262
=== modified file 'plugins/pinyin/src/chineselanguagefeatures.cpp'
--- plugins/pinyin/src/chineselanguagefeatures.cpp 2015-02-09 21:14:24 +0000
+++ plugins/pinyin/src/chineselanguagefeatures.cpp 2016-08-18 13:50:50 +0000
@@ -56,7 +56,7 @@
5656
57bool ChineseLanguageFeatures::isSeparator(const QString &text) const57bool ChineseLanguageFeatures::isSeparator(const QString &text) const
58{58{
59 static const QString separators = QString::fromUtf8("。、,!?:;.\r\n");59 static const QString separators = QString::fromUtf8("。、,!?:;.…\r\n");
6060
61 if (text.isEmpty()) {61 if (text.isEmpty()) {
62 return false;62 return false;
6363
=== modified file 'plugins/westernsupport/westernlanguagefeatures.cpp'
--- plugins/westernsupport/westernlanguagefeatures.cpp 2016-06-09 15:12:25 +0000
+++ plugins/westernsupport/westernlanguagefeatures.cpp 2016-08-18 13:50:50 +0000
@@ -77,7 +77,7 @@
7777
78bool WesternLanguageFeatures::isSeparator(const QString &text) const78bool WesternLanguageFeatures::isSeparator(const QString &text) const
79{79{
80 static const QString separators = QString::fromUtf8(",.!?:;\r\n");80 static const QString separators = QString::fromUtf8(",.!?:;…\r\n");
8181
82 if (text.isEmpty()) {82 if (text.isEmpty()) {
83 return false;83 return false;
8484
=== modified file 'src/view/abstracttexteditor.cpp'
--- src/view/abstracttexteditor.cpp 2016-06-15 12:44:24 +0000
+++ src/view/abstracttexteditor.cpp 2016-08-18 13:50:50 +0000
@@ -205,6 +205,7 @@
205 int ignore_next_cursor_position;205 int ignore_next_cursor_position;
206 QString ignore_next_surrounding_text;206 QString ignore_next_surrounding_text;
207 bool look_for_a_double_space;207 bool look_for_a_double_space;
208 bool look_for_a_triple_space;
208 bool double_space_full_stop_enabled;209 bool double_space_full_stop_enabled;
209 bool editing_middle_of_text;210 bool editing_middle_of_text;
210 QString appendix_for_previous_preedit;211 QString appendix_for_previous_preedit;
@@ -236,6 +237,7 @@
236 , ignore_next_cursor_position(-1)237 , ignore_next_cursor_position(-1)
237 , ignore_next_surrounding_text()238 , ignore_next_surrounding_text()
238 , look_for_a_double_space(false)239 , look_for_a_double_space(false)
240 , look_for_a_triple_space(false)
239 , double_space_full_stop_enabled(false)241 , double_space_full_stop_enabled(false)
240 , editing_middle_of_text(false)242 , editing_middle_of_text(false)
241 , appendix_for_previous_preedit()243 , appendix_for_previous_preedit()
@@ -356,6 +358,7 @@
356 QString keyText = QString("");358 QString keyText = QString("");
357 Qt::Key event_key = Qt::Key_unknown;359 Qt::Key event_key = Qt::Key_unknown;
358 bool look_for_a_double_space = d->look_for_a_double_space;360 bool look_for_a_double_space = d->look_for_a_double_space;
361 bool look_for_a_triple_space = d->look_for_a_triple_space;
359 bool email_detected = false;362 bool email_detected = false;
360363
361 // Detect if the user is entering an email address and avoid spacing, autocaps and autocomplete changes364 // Detect if the user is entering an email address and avoid spacing, autocaps and autocomplete changes
@@ -368,8 +371,11 @@
368 email_detected = true;371 email_detected = true;
369 }372 }
370373
374 // we reset the flags here so that we won't have to add boilerplate code later
375 if (d->look_for_a_triple_space) {
376 d->look_for_a_triple_space = false;
377 }
371 if (look_for_a_double_space) {378 if (look_for_a_double_space) {
372 // we reset the flag here so that we won't have to add boilerplate code later
373 d->look_for_a_double_space = false;379 d->look_for_a_double_space = false;
374 }380 }
375381
@@ -464,6 +470,7 @@
464 case Key::ActionSpace: {470 case Key::ActionSpace: {
465 QString space = " ";471 QString space = " ";
466 QString textOnLeft = d->text->surroundingLeft() + d->text->preedit();472 QString textOnLeft = d->text->surroundingLeft() + d->text->preedit();
473 QString textOnLeftTrimmed = textOnLeft.trimmed();
467 QStringList textOnRightList = d->text->surroundingRight().split("\n");474 QStringList textOnRightList = d->text->surroundingRight().split("\n");
468 QString textOnRight;475 QString textOnRight;
469 if (!textOnRightList.isEmpty()) {476 if (!textOnRightList.isEmpty()) {
@@ -485,6 +492,14 @@
485 }492 }
486 }493 }
487494
495 // Delete automatically inserted full stop if the user continues
496 // pressing space after a double space.
497 if (look_for_a_triple_space) {
498 singleBackspace();
499 singleBackspace();
500 d->text->appendToPreedit(" ");
501 }
502
488 if (replace_preedit) {503 if (replace_preedit) {
489 if (!textOnRight.isEmpty() && d->editing_middle_of_text) {504 if (!textOnRight.isEmpty() && d->editing_middle_of_text) {
490 // Don't insert a space if we are correcting a word in the middle of a sentence505 // Don't insert a space if we are correcting a word in the middle of a sentence
@@ -512,7 +527,18 @@
512 d->previous_preedit_position -= 1;527 d->previous_preedit_position -= 1;
513 }528 }
514 }529 }
515 else if (look_for_a_double_space && not stopSequence.isEmpty() && textOnLeft.at(textOnLeft.count() - 1).isSpace()) {530 // Only insert a full stop after double space if there isn't already
531 // a separator, and there isn't a separator immediately prior to a ')'
532 else if (look_for_a_double_space
533 && not stopSequence.isEmpty()
534 && textOnLeft.count() >= 2
535 && textOnLeft.at(textOnLeft.count() - 1).isSpace()
536 && !textOnLeft.at(textOnLeft.count() - 2).isSpace()
537 && textOnLeftTrimmed.count() > 0
538 && !d->word_engine->languageFeature()->isSeparator(textOnLeftTrimmed.at(textOnLeftTrimmed.count() - 1))
539 && !(textOnLeftTrimmed.endsWith(")")
540 && textOnLeftTrimmed.count() > 1
541 && d->word_engine->languageFeature()->isSeparator(textOnLeftTrimmed.at(textOnLeftTrimmed.count() - 2)))) {
516 removeTrailingWhitespaces();542 removeTrailingWhitespaces();
517 if (!d->word_engine->languageFeature()->commitOnSpace()) {543 if (!d->word_engine->languageFeature()->commitOnSpace()) {
518 // Commit when inserting a fullstop if we don't insert on spaces544 // Commit when inserting a fullstop if we don't insert on spaces
@@ -529,6 +555,7 @@
529 textOnLeft = d->text->surroundingLeft() + d->text->preedit();555 textOnLeft = d->text->surroundingLeft() + d->text->preedit();
530 auto_caps_activated = d->word_engine->languageFeature()->activateAutoCaps(textOnLeft);556 auto_caps_activated = d->word_engine->languageFeature()->activateAutoCaps(textOnLeft);
531 full_stop_inserted = true;557 full_stop_inserted = true;
558 d->look_for_a_triple_space = true;
532 }559 }
533560
534 d->text->appendToPreedit(space);561 d->text->appendToPreedit(space);
535562
=== modified file 'tests/unittests/ut_editor/ut_editor.cpp'
--- tests/unittests/ut_editor/ut_editor.cpp 2014-12-04 17:44:17 +0000
+++ tests/unittests/ut_editor/ut_editor.cpp 2016-08-18 13:50:50 +0000
@@ -118,7 +118,17 @@
118 QTest::newRow("auto-correct enabled, commit with separators, check separators")118 QTest::newRow("auto-correct enabled, commit with separators, check separators")
119 << true << "Hel. Wor." << "Hello. World.";119 << true << "Hel. Wor." << "Hello. World.";
120 QTest::newRow("auto-correct enabled, check if two spaces are full-stop")120 QTest::newRow("auto-correct enabled, check if two spaces are full-stop")
121 << true << "Hel " << "Hello . "; 121 << true << "Hel " << "Hello . ";
122 QTest::newRow("auto-correct enabled, check two spaces don't insert full-stop after .")
123 << true << "Hello. " << "Hello. ";
124 QTest::newRow("auto-correct enabled, check two spaces don't insert full-stop after !")
125 << true << "Hello! " << "Hello! ";
126 QTest::newRow("auto-correct enabled, check two spaces don't insert full-stop after ?")
127 << true << "Hello? " << "Hello? ";
128 QTest::newRow("auto-correct enabled, check two spaces don't insert full-stop after ...")
129 << true << "Hello... " << "Hello... ";
130 QTest::newRow("auto-correct enabled, check two spaces does insert full-stop after )")
131 << true << "(Hello) " << "(Hello) . ";
122 //QTest::newRow("auto-correct enabled, check removal of unnecessary whitespaces")132 //QTest::newRow("auto-correct enabled, check removal of unnecessary whitespaces")
123 // << true << "Hello. . " << "Hello.. ";133 // << true << "Hello. . " << "Hello.. ";
124 }134 }

Subscribers

People subscribed via source and target branches