-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Injections are not properly parsed with smoothscroll
and spell
enabled
#29452
Comments
smoothscroll
and spell
enabled
I doubt the fix for this will be in the smoothscroll/draw code. I'd image the treesitter runtime code(which I'm not at all familiar with) fails somewhere due to an incorrect/unexpected start_col or something? |
Yes, the "smoothscroll" does not notify the treesitter code about the shifted viewport (like a regular scroll does) so the newly visible injections are not parsed like they should. My suspicion is that there's a decoration provider ( |
The thing is that that is not possible, the smoothscroll code is quite far removed from the actual drawing. Any window that is drawn will first trigger on_win, any line that is drawn first triggers on_line. |
Yeah this regressed in #26614. Following diff restores the highlighting. I haven't looked in as to what would be a reasonable adjustment to this logic to make it work with a smoothscrolled topline. diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua
index 003f7e0169..424743f23a 100644
--- a/runtime/lua/vim/treesitter/highlighter.lua
+++ b/runtime/lua/vim/treesitter/highlighter.lua
@@ -181,9 +181,9 @@ function TSHighlighter:prepare_highlight_states(srow, erow)
local root_start_row, _, root_end_row, _ = root_node:range()
-- Only consider trees within the visible range
- if root_start_row > erow or root_end_row < srow then
- return
- end
+ -- if root_start_row > erow or root_end_row < srow then
+ -- return
+ -- end
local highlighter_query = self:get_query(tree:lang()) |
Uhm the actual issue here is that the In this repro that just clears the correctly on_win populated "highlight state". But I'm not sure what the |
OK after reading into this some more this seems like an appropriate fix: diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua
index 003f7e0169..1eba07c080 100644
--- a/runtime/lua/vim/treesitter/highlighter.lua
+++ b/runtime/lua/vim/treesitter/highlighter.lua
@@ -377,11 +377,13 @@ function TSHighlighter._on_spell_nav(_, _, buf, srow, _, erow, _)
return
end
+ 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 From what I understand, |
Problem
Recording.2024-06-22.233322.mp4
Steps to reproduce
Here is my minimal config.
I download
nvim-treesitter
vialazy.nvim
and clone the plugin in intonvim-data/nvim-treesitter
and removelazy.nvim
to ensure a minimal configuration.This two settings are essential.
It is only when I enable the both that the problem arises.
Here is the output of
:checkhealth nvim-treesitter
Here is my .md file used in the video.
j.md
Expected behavior
The blue color should not vanish when the top of the buffer passes through the long paragraph.
Neovim version (nvim -v)
NVIM v0.10.0
Vim (not Nvim) behaves the same?
I don't know, I think the
nvim-treesitter
plugin is for neovim only.Operating system/version
Windows 11 Home China
Terminal name/version
PowerShell 7.4.3
$TERM environment variable
I think it is not important.
Installation
nvim-win64.zip, latest release.
The text was updated successfully, but these errors were encountered: