From 8af2f0f18350078ae8d70a62c95e161b2d43a0af Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 28 Aug 2020 16:42:52 +0200 Subject: don't stop iterating over typos when an empty one is encountered An iterator in lua stops if it returns nil. This change will get a new typo from the unfiltered_iterator if we encounter an empty one instead of returning nil. --- spellcheck.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spellcheck.lua b/spellcheck.lua index de04cea..6a20172 100644 --- a/spellcheck.lua +++ b/spellcheck.lua @@ -84,9 +84,9 @@ local function typo_iter(text, typos, ignored) return function(foo, bar) repeat typo = unfiltered_iterator(iter_state) - until(not typo or not ignored[typo]) + until(not typo or (typo ~= "" and not ignored[typo])) - if typo and typo ~= "" then + if typo then -- 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. -- cgit