diff options
| -rw-r--r-- | spellcheck.lua | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/spellcheck.lua b/spellcheck.lua index 59c5630..fe7d8a3 100644 --- a/spellcheck.lua +++ b/spellcheck.lua @@ -86,9 +86,14 @@ local function typo_iter(text, typos, ignored) until(not typo or not ignored[typo]) if typo then - local start, finish = text:find(typo, index, true) + -- to prevent typos from being found in correct words before them + -- ("stuff stuf", "broken ok", ...) + -- we match typos only when they are enclosed in non-letter characters. + local start, finish = text:find("[%A]" .. typo .. "[%A]", index) index = finish - return typo, start, finish + + -- ignore the first and last non letter character + return typo, start + 1, finish - 1 end end end |
