From dfd0a30d09b8c8647911ae596ec14f3d6ae1ee7e Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 23 Sep 2026 09:53:05 +0200 Subject: clear token cache when toggling syntax aware spellchecking --- spellcheck.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spellcheck.lua b/spellcheck.lua index c2f4971..b8d68a0 100644 --- a/spellcheck.lua +++ b/spellcheck.lua @@ -307,6 +307,8 @@ local enable_spellcheck = function() lexer.lex = wrap_lex_func(old_lex_func) -- reset last data to enforce new highlighting last_data = '' + -- clear token cache to relex the window + if vis.win.token_cache then vis.win.token_cache = {} end return end end @@ -335,6 +337,8 @@ local disable_spellcheck = function() local lexer = vis.lexers.load(vis.win.syntax, nil, true) lexer.lex = old_lex_func wrapped_lex_funcs[vis.win] = nil + -- clear token cache to relex the window + if vis.win.token_cache then vis.win.token_cache = {} end else spellcheck.check_full_viewport[vis.win] = nil end @@ -354,8 +358,8 @@ vis:map(vis.modes.NORMAL, '', function() enable_spellcheck() else disable_spellcheck() - vis.win:draw() end + vis.win:draw() return 0 end, 'Toggle spellchecking in the current window') -- cgit v1.2.3