From 0af6d6ff5e0ad6d38e200c6b84b9cc22aecb1378 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 31 May 2025 16:49:20 +0800 Subject: [PATCH] vim-patch:9.1.1147: preview-window does not scroll correctly Problem: preview-window does not scroll correctly Solution: init firstline = 0 for a preview window (Girish Palya) The 'info' window, which appears during insert-mode completion to display additional information, was not scrolling properly when using commands like: win_execute(popup_findinfo(), "normal! \") This issue made it impossible to navigate through info window contents using keyboard-based scrolling. The fix correctly updates the w_firstline value of the popup window, ensuring proper scrolling behavior. Mouse scrolling was already working as expected and remains unaffected. closes: vim/vim#16703 https://github.com/vim/vim/commit/12b1eb58abca1eabc4833ad855c8a31d8b40981e Co-authored-by: Girish Palya --- test/old/testdir/test_ins_complete.vim | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim index bfdc9d13a2..0d434386ea 100644 --- a/test/old/testdir/test_ins_complete.vim +++ b/test/old/testdir/test_ins_complete.vim @@ -473,6 +473,53 @@ func Test_completefunc_info() set completefunc& endfunc +func ScrollInfoWindowUserDefinedFn(findstart, query) + " User defined function (i_CTRL-X_CTRL-U) + if a:findstart + return col('.') + endif + let infostr = range(20)->mapnew({_, v -> string(v)})->join("\n") + return [{'word': 'foo', 'info': infostr}, {'word': 'bar'}] +endfunc + +func ScrollInfoWindowPageDown() + call win_execute(popup_findinfo(), "normal! \") + return '' +endfunc + +func ScrollInfoWindowPageUp() + call win_execute(popup_findinfo(), "normal! \") + return '' +endfunc + +func ScrollInfoWindowTest(mvmt, count, fline) + new + set completeopt=menuone,popup,noinsert,noselect + set completepopup=height:5 + set completefunc=ScrollInfoWindowUserDefinedFn + let keyseq = "i\\\" + for _ in range(a:count) + let keyseq .= (a:mvmt == "pageup" ? "\\=ScrollInfoWindowPageUp()\" : + \ "\\=ScrollInfoWindowPageDown()\") + endfor + let keyseq .= "\\=string(popup_getpos(popup_findinfo()))\\" + call feedkeys(keyseq, "tx") + call assert_match('''firstline'': ' . a:fline, getline(1)) + bwipe! + set completeopt& + set completepopup& + set completefunc& +endfunc + +func Test_scroll_info_window() + throw 'Skipped: popup_findinfo() is N/A' + call ScrollInfoWindowTest("", 0, 1) + call ScrollInfoWindowTest("pagedown", 1, 4) + call ScrollInfoWindowTest("pagedown", 2, 7) + call ScrollInfoWindowTest("pagedown", 3, 11) + call ScrollInfoWindowTest("pageup", 3, 1) +endfunc + func CompleteInfoUserDefinedFn(findstart, query) " User defined function (i_CTRL-X_CTRL-U) if a:findstart