kdeui: fix spell check of words at ends

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-11 14:39:22 +03:00
parent bb1e962276
commit 2b45ac1a73
2 changed files with 4 additions and 4 deletions

View file

@ -278,8 +278,8 @@ void KSpeller::start()
const bool atseparator = KSpeller::isWordSeparator(d->text.at(counter));
if (!atseparator && wordstart == -1) {
wordstart = counter;
} else if (atseparator && wordstart != -1) {
const QString word = d->text.mid(wordstart, counter - wordstart);
} else if ((atseparator || (counter + 1) == d->text.size()) && wordstart != -1) {
const QString word = d->text.mid(wordstart, counter - wordstart + (atseparator ? 0 : 1));
// not worth checking if it is less than two characters
if (word.size() >= 2) {
// qDebug() << Q_FUNC_INFO << wordstart << counter << word;

View file

@ -101,8 +101,8 @@ void KSpellHighlighter::highlightBlock(const QString &text)
const bool atseparator = KSpeller::isWordSeparator(text.at(counter));
if (!atseparator && wordstart == -1) {
wordstart = counter;
} else if (atseparator && wordstart != -1) {
const QString word = text.mid(wordstart, counter - wordstart);
} else if ((atseparator || (counter + 1) == text.size()) && wordstart != -1) {
const QString word = text.mid(wordstart, counter - wordstart + (atseparator ? 0 : 1));
// not worth checking if it is less than two characters
if (word.size() >= 2) {
if (!d->speller.check(word)) {