fix(treesitter): no injection highlighting on last line #36951

Problem:
If the last visible line in a window is not fully displayed, this line
may not get injection highlighting. This happens because line('w$')
actually means the last *completely displayed* line.

Solution:
Use line('w$') + 1 for the botline.

This reverts 4244a96774
"test: fix failing lsp/utils_spec #36609",
which changed the test based on the wrong behavior.
This commit is contained in:
Jaehwang Jung
2025-12-15 09:01:49 +09:00
committed by GitHub
parent 592582ba48
commit 63737e6e73
2 changed files with 6 additions and 3 deletions

View File

@@ -561,7 +561,10 @@ function TSHighlighter._on_start()
if not buf_ranges[buf] then
buf_ranges[buf] = {}
end
local topline, botline = vim.fn.line('w0', win) - 1, vim.fn.line('w$', win)
local topline = vim.fn.line('w0', win) - 1
-- +1 because w$ is the last completely displayed line (w_botline - 1), which may be -1 of the
-- last line that is at least partially visible.
local botline = vim.fn.line('w$', win) + 1
table.insert(buf_ranges[buf], { topline, botline })
end
end