d12frosted / flyspell-correct

Distraction-free words correction with flyspell via selected interface.
Other
203 stars 14 forks source link

Flyspell-correct-ivy doesn't work is previous error is a duplicate #29

Closed thblt closed 7 years ago

thblt commented 7 years ago

Steps to reproduce

Enter this sentence in a random buffer:

The sixth word in this sentnece is misspelled, but because the the twelfth word is a duplicate, flyspell-correct-ivy doesn't work.

Two words are marked by Flyspell (I put them in bold): the obviously misspelled "sentnece" and the duplicated "the" ("the the twelfth"), because Flyspell warns about duplicated words. Trying to run flyspell-correct-ivy with the point at the end of the sentence (or anywhere after the double "the") has absolutely no effect.

Expected behavior

Thanks! Th

d12frosted commented 7 years ago

Wow, indeed! Thanks for the detailed report.

Functions that correct word before or after the point are using flyspell-overlay-p which is used to filter out all overlays. I am not sure what is the best way to filter out these overlays, but it seems that there is a special face for duplicate overlays and incorrect words. So I can just filter out 'duplicate' overlays 😸

In case you don't know better solution - I will implement this one till tomorrow.

thblt commented 7 years ago

Sounds good, with a very small edge case: a repeated and misspelled word would be ignored. I haven't dug into flyspell[-correct] code, but wouldn't it be easier (and less dependant on font-locking and/or local buffer idiosyncrasies) to simply skip the word is Flyspell considers it valid?

[1] Focus on previous marked word [=the]
[2] Is the word valid?
    [3] Yes -> Goto 1
    [4] No -> 
        [5] run flyspell-correct popup
        [6] exit

Using the example sentence above, the process would run: focus on "the", internally verify "the" using flycheck, "the" is valid and should not be corrected (state 4), focus on previous error, focus is now on "sentnece", "sentnece" is not valid, display flyspell-correct popup.

d12frosted commented 7 years ago

Yeah that makes sense. And looks like a better solution. Thanks.

d12frosted commented 7 years ago

Sorry for the delay. I have pushed fix. Should be available in MELPA soon. Let me know if I screwed anything 😸

In case everything is fine - I'll release new stable version with this fix.

thblt commented 7 years ago

Just tested the version in Melpa and everything seems fine. Thanks for the fix, and thanks in advance for the tagged release!