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.
This commit is contained in:
Luuk van Baal
2024-06-23 13:50:21 +02:00
committed by Lewis Russell
parent be999e6a0e
commit da4e8dc5b0
2 changed files with 41 additions and 28 deletions

View File

@@ -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