From 902a85361dd81eecd944da8d00e8195e1f8c5e06 Mon Sep 17 00:00:00 2001 From: jensenojs Date: Wed, 11 Nov 2026 19:29:23 +0800 Subject: [PATCH] test(cursor_tracking): scroll for real instead of reading a stale w$ after winrestview The wrapped-window is_at_bottom test restored topline=1 via winrestview and immediately read line('w$', win) without a redraw. Since neovim#37047 (commit 033f112) line('w$', win) validates the target window without switching curwin, so on nightly the read returns the pre-restore viewport's bottom line and the assertion fails. Scrolling with normal! gg settles the viewport on every version: verified the spec passes on nvim 0.12.6 and nightly (v0.13.0-dev-2081). --- tests/unit/cursor_tracking_spec.lua | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/unit/cursor_tracking_spec.lua b/tests/unit/cursor_tracking_spec.lua index 94d3e4d5..fcc64e4f 100644 --- a/tests/unit/cursor_tracking_spec.lua +++ b/tests/unit/cursor_tracking_spec.lua @@ -317,17 +317,14 @@ describe('output_window.is_at_bottom', function() vim.api.nvim_win_set_width(win, 20) vim.api.nvim_set_option_value('wrap', true, { win = win, scope = 'local' }) vim.api.nvim_buf_set_lines(buf, 0, -1, false, { 'line 1', 'line 2', long_line, 'line 4', 'line 5' }) - vim.api.nvim_win_set_cursor(win, { 5, 0 }) - pcall(vim.api.nvim_win_call, win, function() - vim.fn.winrestview({ topline = 1 }) + vim.api.nvim_win_call(win, function() + vim.cmd('normal! gg') end) local visible_bottom = output_window.get_visible_bottom_line(win) - -- With topline=1, height=10, wrap=true, width=20: - -- line 1 (1 row), line 2 (1 row), long_line (180/20=9 rows). - -- In headless Neovim the visible bottom is line 3 (the long wrapped line) - -- or line 2 depending on the environment's redraw behaviour. - -- The important property is that it is not the last buffer line (5). + -- Scrolled to top with topline=1, height=10, wrap=true, width=20: + -- line 1 (1 row), line 2 (1 row), long_line (180/20=9 rows, cut off). + -- The last completely visible line is 2, never the last buffer line (5). assert.is_true(visible_bottom ~= nil) assert.is_true(visible_bottom < 5) end)