diff options
author | Florian Fischer <florian.fl.fischer@fau.de> | 2020-08-28 13:11:26 +0200 |
---|---|---|
committer | Florian Fischer <florian.fl.fischer@fau.de> | 2020-08-28 13:11:26 +0200 |
commit | bf3badc73dc5d43df3aab9070cf9faef37b96326 (patch) | |
tree | 3f4eb44e3ee769bfab437eec3ac19a4060a2b5ee /spellcheck.lua | |
parent | 96bf9b1b50c641671390ef4e9d84206c69137150 (diff) | |
download | vis-spellcheck-bf3badc73dc5d43df3aab9070cf9faef37b96326.tar.gz |
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.
Diffstat (limited to 'spellcheck.lua')
-rw-r--r-- | spellcheck.lua | 14 |
1 files changed, 7 insertions, 7 deletions
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 |