From 8ceea17969a2a2aaa611a5f5c87a197dabfb005f Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 7 Jan 2021 12:54:44 +0100 Subject: 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. --- spellcheck.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'spellcheck.lua') 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, "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") -- cgit v1.2.3