diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2021-01-07 12:54:44 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2021-01-07 12:54:44 +0100 |
| commit | 8ceea17969a2a2aaa611a5f5c87a197dabfb005f (patch) | |
| tree | da47a9175e87ac51b9fdbd030835382d6a9abe61 /spellcheck.lua | |
| parent | cc24d1848702077a85e114ced28b256d9f9c41bb (diff) | |
| download | vis-spellcheck-8ceea17969a2a2aaa611a5f5c87a197dabfb005f.tar.gz vis-spellcheck-8ceea17969a2a2aaa611a5f5c87a197dabfb005f.zip | |
fix ignoring of words for the syntax aware lex-closure approach
Because the lexer.lex wrapper function is a closure it saves the
state of the ignored word table in the closure.
Therefore to see the effect of ignoring words we must rebuild the wrapper
closure.
Diffstat (limited to 'spellcheck.lua')
| -rw-r--r-- | spellcheck.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/spellcheck.lua b/spellcheck.lua index d6483df..080a1aa 100644 --- a/spellcheck.lua +++ b/spellcheck.lua @@ -374,6 +374,17 @@ vis:map(vis.modes.NORMAL, "<C-w>i", function(keys) ignored[file:content(range)] = true + -- Check if we use our syntax aware spellcheck lex-closure + -- We must rebuild the closure because it captures ignored + -- to include the new addition + local old_lex_func = wrapped_lex_funcs[vis.win] + if old_lex_func then + local lexer = vis.lexers.load(vis.win.syntax, nil, true) + lexer.lex = wrap_lex_func(old_lex_func) + -- reset last data to enforce new highlighting + last_data = "" + end + win:draw() return 0 end, "Ignore misspelled word") |
