aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2020-08-27 14:10:09 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2020-08-27 14:10:09 +0200
commitc0eef2f85a44e4bbaac1af27f428dfd22ebd06ab (patch)
treeab9ab513a84327f2edca678b43fc04e56e39badf
parentebdd1360935b8c27eae6929042b0386af3e2e43b (diff)
downloadvis-spellcheck-c0eef2f85a44e4bbaac1af27f428dfd22ebd06ab.tar.gz
fix highlighting of typos at the end of the text
Our pattern [%A]<typo>[%A] does not match typos at the end or start of the text because there is no leading / trailing non letter character. So if we dind't find the typo with our normal pattern it must be either the start or the end of the text. If not raise a warning that this must be a bug.
-rw-r--r--spellcheck.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/spellcheck.lua b/spellcheck.lua
index 782fe8f..89d2bd7 100644
--- a/spellcheck.lua
+++ b/spellcheck.lua
@@ -91,6 +91,13 @@ local function typo_iter(text, typos, ignored)
-- ("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)
+ -- the typo was not found by our pattern this means it must be the last word in the text
+ if not start then
+ start, finish = text:find("[%A]" .. typo .. "$", index)
+ if not start then
+ vis:info(string.format("typo %s not found after %d this must be a bug please report", typo, index))
+ end
+ end
index = finish
-- ignore the first and last non letter character