SpellCheck: Fix markup rebasing when simple edits are done (one char added)
AbandonedPublic

Authored by danders on Aug 10 2017, 10:58 AM.

Details

Reviewers
boemann
Summary

Rebasing was done using parameters from QTextDocument::contentsChange() signal incorrectly.
This caused the markup to be displayed in wrong position, and sometimes in an assert
in KoTextBlockData::appendMarkup().

This patch depends on that a simple edit is always the same as adding one character.

Test Plan

I found this method the easiest way to trigger the assert:
Add a (long) line with spelling mistakes.
Save to file.
Open file and position at the end of the line.
Quickly add a few words.

Diff Detail

Repository
R8 Calligra
Branch
spellcheck_markup_danders
Lint
No Linters Available
Unit
No Unit Test Coverage
danders created this revision.Aug 10 2017, 10:58 AM
Restricted Application added a project: Calligra: 3.0. · View Herald TranscriptAug 10 2017, 10:58 AM
boemann edited edge metadata.Aug 10 2017, 12:54 PM

Not quite

simple edit could also be simple deletions and removes iirc

it seems to me that your assumption should at least be tested. ie added==1 && removed ==0, before just rebasing with +1

Iirc simple editing is to just move the other words after so they are still placed correctly
then later when the cursor leaves the word that word is spellchecked (possibly the entire block at that pooint, though i can't remember)

Camilla Boemann skrev den 2017-08-10 14:54:

boemann added a comment.
View Revision [1]

Not quite

simple edit could also be simple deletions and removes iirc

No, I don't think so. Looking at the code (and testing) shows
startingSimpleEdit() is called only on insert character.

it seems to me that your assumption should at least be tested. ie
added==1 && removed ==0, before just rebasing with +1

Yeah, thought so too, but it seems that
QTextDocument::contentsChange(from, removed, added) is emitted with:
from: always 0 (or it might be
removed: length of complete text before edit
added: length of complete text after edit

So, imho useless, but I might have missed a trick.

To make it a little bit more robust in case of upstream changes, I could
check:
added == removed + 1
Hmmm, I think a number of asserts would be the thing, to detect upstream
changes.

Iirc simple editing is to just move the other words after so they are
still placed correctly
then later when the cursor leaves the word that word is spellchecked
(possibly the entire block at that pooint, though i can't remember)

Yes, the intention of this code is to keep the markup in the correct
place and to avoid spellchecking until a complete word has been entered.
But afaics the whole doc will be spellchecked, as the code iterates over
all blocks.

REPOSITORY

R8 Calligra
REVISION DETAIL
https://phabricator.kde.org/D7228
TO: danders, boemann
CC: vandenoever

Links:


[1] https://phabricator.kde.org/D7228

But afaics the whole doc will be spellchecked, as the code iterates over
all blocks.

I wouldn't be surprised no - there are issues like that for sure

And also on initiating a spellcheck when just loading the doc iirc

danders abandoned this revision.Mar 13 2020, 10:14 AM

Has been comitted

Restricted Application added a subscriber: Calligra-Devel-list. · View Herald TranscriptMar 13 2020, 10:14 AM