RickStrahl / MarkdownMonster

An extensible Markdown Editor, Viewer and Weblog Publisher for Windows
https://markdownmonster.west-wind.com
Other
1.58k stars 236 forks source link

Bug: Spellings correction uses wronge replacement positions when using special character (') single quote #1101

Closed Anynomouss closed 5 months ago

Anynomouss commented 5 months ago

Example text: 'Text' using four 'single-quotes', results in an erroneous underlining and spellings correction and should be fixed where possibleible, right click will suggest to change possibleible to possible.

I only noticed this problem in a certain section of my document so I did some further investigation . It turned out to be the use of single quotes ('), see the example text provided above. I had four single quotes in my text that turned out not to be counted when underlining a wrongfully spelled words, resulting in a shift to the left. When I removed 2 out of 4 of these (') the shift was only 2, when I removed them altogether, replacement worked like normal, confirming the problem occurred when using (') in text.

Solution Solution: Depends on how you implemented this. Perhaps you use a parsed format of the text where characters like (') are removed before feeding the text to the spellings correction library. I checked all characters on my keyboard and for me it only appears to happen when using (') single quote characters, but perhaps you can double check which characters are replaced in the code.

1) Use a string replacements or search to find the correct location of a to be underlined word/string. 2) Count the replacements characters in the text up to the point of the to be underlined string and add these to the location given by the text corrector.

A free Markdown Monster subscriptions is appreciated ;)

RickStrahl commented 5 months ago

Whoa good catch! This has been around for a while but I've never put it together that it was based on the quotes.

Looks like any quote offsets the misspelling underline to the left. Looks like the counter is skipping quotes.

I'll take a look.

RickStrahl commented 5 months ago

Ok found the issue. Looks like it's working now:

image

This will also now work with double quotes (didn't before).