aboutsummaryrefslogtreecommitdiffstats
path: root/src/virtualkeyboard/shifthandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/virtualkeyboard/shifthandler.cpp')
-rw-r--r--src/virtualkeyboard/shifthandler.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/virtualkeyboard/shifthandler.cpp b/src/virtualkeyboard/shifthandler.cpp
index d268282e..b2d44f95 100644
--- a/src/virtualkeyboard/shifthandler.cpp
+++ b/src/virtualkeyboard/shifthandler.cpp
@@ -298,14 +298,14 @@ void ShiftHandler::autoCapitalize()
bool preferLowerCase = d->inputContext->inputMethodHints() & Qt::ImhPreferLowercase;
if (cursorPosition == 0) {
setShiftActive(!preferLowerCase);
- } else {
+ } else { // space after sentence-ending character triggers auto-capitalization
QString text = d->inputContext->surroundingText();
text.truncate(cursorPosition);
- text = text.trimmed();
- if (text.length() == 0)
- setShiftActive(!preferLowerCase);
- else if (text.length() > 0 && d->sentenceEndingCharacters.indexOf(text[text.length() - 1]) >= 0)
+ if (text.trimmed().length() == 0)
setShiftActive(!preferLowerCase);
+ else if (text.endsWith(QLatin1Char(' ')))
+ setShiftActive(d->sentenceEndingCharacters.contains(text.rightRef(2)[0])
+ && !preferLowerCase);
else
setShiftActive(false);
}