From bf3badc73dc5d43df3aab9070cf9faef37b96326 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 28 Aug 2020 13:11:26 +0200 Subject: Don't fail if the first and only typo is at the end of the text. Before this change we assumed that when we are at the beginning of the text (index == 1) and don't find the typo is must be the beginning of the text but it can also be the end of the text. We now also check the end if the beginning was not what we were lookig for. --- spellcheck.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'spellcheck.lua') diff --git a/spellcheck.lua b/spellcheck.lua index aa0f662..5b374c2 100644 --- a/spellcheck.lua +++ b/spellcheck.lua @@ -95,19 +95,19 @@ local function typo_iter(text, typos, ignored) -- the first or last word in the text if not start then -- check start of text - if index == 1 then - start = index - finish = #typo - -- must be the end of text - else + start = 1 + finish = #typo + -- typo is not the beginning must be the end of text + if text:sub(start, finish) ~= typo then start = #text - #typo + 1 finish = start + #typo - 1 end if text:sub(start, finish) ~= typo then - vis:info(string.format("typo %s not where expected after %d at %d %d found: %s", - typo, index, start, finish, text:sub(start, finish))) + vis:info(string.format("can't find typo %s after %d. Please report this bug.", + typo, index)) end + -- our pettern [%A]typo[%A] found it else start = start + 1 -- ignore leading non letter char finish = finish - 1 -- ignore trailing non letter char -- cgit v1.2.3