From d8cea8d45d6602e3e4b9624e12dd14938440ff37 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Fri, 10 Oct 2025 16:05:40 +0200 Subject: [PATCH] fix(ui2): don't scroll beyond eob in dialog window #36116 Problem: Forward page scrolling reveals eob lines in the dialog window. Solution: Check if the end of the buffer is visible before scrolling down. --- runtime/lua/vim/_extui/messages.lua | 6 +++--- test/functional/ui/messages2_spec.lua | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/runtime/lua/vim/_extui/messages.lua b/runtime/lua/vim/_extui/messages.lua index f3528936a0..3bd18b07ed 100644 --- a/runtime/lua/vim/_extui/messages.lua +++ b/runtime/lua/vim/_extui/messages.lua @@ -544,11 +544,11 @@ function M.set_pos(type) f = [[\]], b = [[\]], } - if page_keys[key] then - local topline = fn.getwininfo(ext.wins.dialog)[1].topline + local info = page_keys[key] and fn.getwininfo(ext.wins.dialog)[1] + if info and (key ~= 'f' or info.botline < api.nvim_buf_line_count(ext.bufs.dialog)) then fn.win_execute(ext.wins.dialog, ('exe "norm! %s"'):format(page_keys[key])) set_top_bot_spill() - return fn.getwininfo(ext.wins.dialog)[1].topline ~= topline and '' or nil + return fn.getwininfo(ext.wins.dialog)[1].topline ~= info.topline and '' or nil end end) elseif type == 'msg' then diff --git a/test/functional/ui/messages2_spec.lua b/test/functional/ui/messages2_spec.lua index 7b7953b221..f3b3321ae0 100644 --- a/test/functional/ui/messages2_spec.lua +++ b/test/functional/ui/messages2_spec.lua @@ -344,7 +344,23 @@ describe('messages2', function() 99 | Type number and or click with the mouse (q or empty cancels): ^ | ]]) - feed('g') + -- No scrolling beyond end of buffer #36114 + feed('f') + screen:expect([[ + | + {1:~ }|*3 + {3:───────────────────────────────────────────────────────────────────────}| + 93 [+93] | + 94 | + 95 | + 96 | + 97 | + 98 | + 99 | + Type number and or click with the mouse (q or empty cancels): f| + ^ | + ]]) + feed('g') screen:expect(top) end)