neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 63737e6e73d4a5c3fdd73b54e6e829c17a2c62b3
parent 592582ba4886d6a9f92920bc5bd9e1217a7476ac
Author: Jaehwang Jung <tomtomjhj@gmail.com>
Date:   Mon, 15 Dec 2025 09:01:49 +0900

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 4244a967746a1476831d990153d4de85450e54d4
"test: fix failing lsp/utils_spec #36609",
which changed the test based on the wrong behavior.
Diffstat:
Mruntime/lua/vim/treesitter/highlighter.lua | 5++++-
Mtest/functional/plugin/lsp/utils_spec.lua | 4++--
2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua @@ -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 diff --git a/test/functional/plugin/lsp/utils_spec.lua b/test/functional/plugin/lsp/utils_spec.lua @@ -357,7 +357,7 @@ describe('vim.lsp.util', function() screen:expect([[ ^ | ┌─────────┐{1: }| - │{101:local foo}│{1: }| + │{100:local}{101: }{102:foo}│{1: }| └─────────┘{1: }| {1:~ }|*9 | @@ -384,7 +384,7 @@ describe('vim.lsp.util', function() screen:expect([[ ^ | ┌─────────┐{1: }| - │{101:local foo}│{1: }| + │{100:local}{101: }{102:foo}│{1: }| └─────────┘{1: }| {1:~ }|*9 |