summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-08-11 07:25:38 +0200
committerMontel Laurent <[email protected]>2016-08-11 07:25:38 +0200
commit5bea8d723d72ab14b750fdbc9e6fd238d1356ecd (patch)
treee9ed90f3de84184ad134b892d76601b4c1e46b8e
parent802c5f54348c2725d9ee1adc0b6dd2840a2cecf2 (diff)
improve autocorrect too
-rw-r--r--src/autocorrection/autocorrection.cpp2
-rw-r--r--src/autocorrection/autotests/autocorrectiontest.cpp14
2 files changed, 16 insertions, 0 deletions
diff --git a/src/autocorrection/autocorrection.cpp b/src/autocorrection/autocorrection.cpp
index 86a3cbf..57a2312 100644
--- a/src/autocorrection/autocorrection.cpp
+++ b/src/autocorrection/autocorrection.cpp
@@ -832,6 +832,8 @@ int AutoCorrection::advancedAutocorrect()
// (Necessary to make sure the first letters match???)
if (actualWord.at(0).isUpper() && replacement.at(0).isLower()) {
replacement[0] = replacement[0].toUpper();
+ } else if (actualWord.at(0).isLower() && replacement.at(0).isUpper()) {
+ replacement[0] = replacement[0].toLower();
}
// If a punctuation mark was on the end originally, add it back on
diff --git a/src/autocorrection/autotests/autocorrectiontest.cpp b/src/autocorrection/autotests/autocorrectiontest.cpp
index 3d72912..0de72a5 100644
--- a/src/autocorrection/autotests/autocorrectiontest.cpp
+++ b/src/autocorrection/autotests/autocorrectiontest.cpp
@@ -467,11 +467,25 @@ void AutoCorrectionTest::shouldAutocorrectMultiWord_data()
map.insert(QStringLiteral("boo"), QStringLiteral("Bla"));
QTest::newRow("withuppercase-3") << QStringLiteral("Boo") << QStringLiteral("Bla") << map;
+ map.clear();
+ map.insert(QStringLiteral("boo"), QStringLiteral("Bla"));
+ QTest::newRow("withuppercase-4") << QStringLiteral("boo") << QStringLiteral("bla") << map;
+
map.clear();
map.insert(QStringLiteral("booooo"), QStringLiteral("bla"));
QTest::newRow("nofindtext") << QStringLiteral("boo") << QStringLiteral("boo") << map;
+ map.clear();
+ map.insert(QStringLiteral("boosss"), QStringLiteral("Blasss"));
+ map.insert(QStringLiteral("boo"), QStringLiteral("bla"));
+ QTest::newRow("withponct") << QStringLiteral("boo!") << QStringLiteral("bla!") << map;
+
+ map.clear();
+ map.insert(QStringLiteral("boosss"), QStringLiteral("Blasss"));
+ map.insert(QStringLiteral("boo"), QStringLiteral("bla"));
+ QTest::newRow("withponct-2") << QStringLiteral("lolo. boo!") << QStringLiteral("lolo. bla!") << map;
+
}
void AutoCorrectionTest::shouldAutocorrectMultiWord()