cargo-spellcheck icon indicating copy to clipboard operation
cargo-spellcheck copied to clipboard

merge exact matches of overlapping suggestion

Open drahnr opened this issue 5 years ago • 1 comments

languagetool includes hunspell on the backend, now both checkers provide a suggestion for the same item, which is pointless to the user and when fixing interactively, this will cause potentially broken file structure - i.e. when replacing the same word twice with words of different length.

Potential Solutions

Short term 🔰:

Using an iteration loop to check if overlaying issues are detected, if so prioritize one over the other (usually language tool provides the better suggestions).

Mid term:

Apply the changes of one checker before running the second checker. That way we have checkpoints.

Long term:

Consider tracking the line changes in chunks and adjust the spans that will be adjusted accordingly.

drahnr avatar Jun 10 '20 10:06 drahnr

In the hindsight, it's probably a non trivial issue to disambiguate (smells like coverage problem on spans).

The 🔰 part is to detect overlaps and discard the secondary, but do another cycle of checking with the provided checkers.

drahnr avatar Nov 15 '20 06:11 drahnr

@drahnr If this is still the issue, can I work on the 🔰 part of this at a minimum? Thanks

granddaifuku avatar Nov 05 '22 11:11 granddaifuku

It is! It actually breaks a few baked in assumptions that changes are atomic and non-overlapping. So the second one can mess up the text after the first got applied with a different character span. Note that the languagetool got replace by nlprules backend, and the priority is more on the correctness of applying changes. Stage 2 would be, to re-reparse comments that had overlapping fixes, but that's not really in the scope of :beginner: anymore.

I'd recommend to take a look at the structure how it works, do a first draft PR, might be just comments!, where you think the changes should go and we can continue the discussion from there :)

drahnr avatar Nov 07 '22 10:11 drahnr