Fix replacement of same word in one line
When one line had the same mispelled word, codespell was incorrectly fixing that line, even introducing new typos. This was because the list of misspelled words is not updated according to the fixes. Instead of always updating this list and making the loop more difficult, we do as following: - Cache the words that are fixed in a certain line - Fix all cases of a misspelled in each line (this means that interactive mode will fix all cases with the same suggestions... not awesome, but simplifies a lot the code) - Use a regex with re.sub() instead of the naive string.replace() function. This eliminates dumb cases of matching partial words and modifying them. Eg.: addres->address would modify addressable to addresssable. - Skip words that were already fixed by previous iteration. Thanks to Bruce Cran <bruce@cran.org.uk> for reporting this issue.
Loading
Please register or sign in to comment