From da4e8dc5b04a82c6dd483f6c5345a81d8b375bec Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sun, 23 Jun 2024 13:50:21 +0200 Subject: fix(treesitter): do not modify highlight state for _on_spell_nav Problem: Treesitter highlighter clears the already populated highlight state when performing spell checking while drawing a smoothscrolled topline. Solution: Save and restore the highlight state in the highlighter's _on_spell_nav callback. --- runtime/lua/vim/treesitter/highlighter.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index 003f7e0169..cd5c67d816 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -377,11 +377,15 @@ function TSHighlighter._on_spell_nav(_, _, buf, srow, _, erow, _) return end + -- Do not affect potentially populated highlight state. Here we just want a temporary + -- empty state so the C code can detect whether the region should be spell checked. + local highlight_states = self._highlight_states self:prepare_highlight_states(srow, erow) for row = srow, erow do on_line_impl(self, buf, row, true) end + self._highlight_states = highlight_states end ---@private -- cgit