From: Girish Palya Date: Mon, 7 Jul 2025 17:47:53 +0000 (+0200) Subject: patch 9.1.1521: completion: pum does not reset scroll pos on reopen with 'noselect' X-Git-Tag: v9.1.1521^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0cd7f3536bde47cf9693090b839abf88c7f019c8;p=thirdparty%2Fvim.git patch 9.1.1521: completion: pum does not reset scroll pos on reopen with 'noselect' Problem: When 'wildmode' is set to include "noselect", the popup menu (pum) incorrectly retained its scroll position when reopened. This meant that after scrolling down through the menu with ``, reopening the menu (e.g., by retyping the command and triggering completion again) would show the menu starting from the previously scrolled position, rather than from the top. This could confuse users, as the first visible item would not be the first actual match in the list. Solution: Ensure that the popup menu resets its scroll position to the top when reopened (Girish Palya). closes: #17673 Signed-off-by: Girish Palya Signed-off-by: Christian Brabandt --- diff --git a/src/cmdexpand.c b/src/cmdexpand.c index 13d540e77d..d5730ab6b3 100644 --- a/src/cmdexpand.c +++ b/src/cmdexpand.c @@ -411,6 +411,7 @@ cmdline_pum_create( // no default selection compl_selected = -1; + pum_clear(); cmdline_pum_display(); return EXPAND_OK; diff --git a/src/testdir/dumps/Test_pum_scroll_noselect_1.dump b/src/testdir/dumps/Test_pum_scroll_noselect_1.dump new file mode 100644 index 0000000000..8e45c8a580 --- /dev/null +++ b/src/testdir/dumps/Test_pum_scroll_noselect_1.dump @@ -0,0 +1,10 @@ +| +0&#ffffff0@7| +0#0000001#ffd7ff255|a|1|5| @11| +0#0000000#a8a8a8255| +0&#ffffff0@49 +|~+0#4040ff13&| @6| +0#0000001#ffd7ff255|a|1|6| @11| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|~| @6| +0#0000001#ffd7ff255|a|1|7| @11| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|~| @6| +0#0000001#ffd7ff255|a|1|8| @11| +0#0000000#0000001| +0#4040ff13#ffffff0@49 +|~| @6| +0#0000001#ffd7ff255|a|1|9| @11| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|~| @6| +0#0000001#e0e0e08|a|2|0| @11| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|~| @6| +0#0000001#ffd7ff255|a|2|1| @11| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|~| @6| +0#0000001#ffd7ff255|a|2@1| @11| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|~| @6| +0#0000001#ffd7ff255|a|2|3| @11| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|:+0#0000000&|T|e|s|t|C|m|d| |a|2|0> @62 diff --git a/src/testdir/dumps/Test_pum_scroll_noselect_2.dump b/src/testdir/dumps/Test_pum_scroll_noselect_2.dump new file mode 100644 index 0000000000..24d8ca84c9 --- /dev/null +++ b/src/testdir/dumps/Test_pum_scroll_noselect_2.dump @@ -0,0 +1,10 @@ +| +0&#ffffff0@7| +0#0000001#ffd7ff255|a|1| @12| +0#0000000#0000001| +0&#ffffff0@49 +|~+0#4040ff13&| @6| +0#0000001#ffd7ff255|a|2| @12| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|~| @6| +0#0000001#ffd7ff255|a|3| @12| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|~| @6| +0#0000001#ffd7ff255|a|4| @12| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|~| @6| +0#0000001#ffd7ff255|a|5| @12| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|~| @6| +0#0000001#ffd7ff255|a|6| @12| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|~| @6| +0#0000001#ffd7ff255|a|7| @12| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|~| @6| +0#0000001#ffd7ff255|a|8| @12| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|~| @6| +0#0000001#ffd7ff255|a|9| @12| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@49 +|:+0#0000000&|T|e|s|t|C|m|d| > @65 diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index c5a7d85c76..6aedf3ec29 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -4622,4 +4622,35 @@ func Test_range_complete() set wildcharm=0 endfunc +" With 'noselect' in 'wildmode', ensure that the popup menu (pum) does not retain +" its scroll position after reopening. The menu should open showing the top items, +" regardless of previous scrolling. +func Test_pum_scroll_noselect() + CheckScreendump + + let lines =<< trim [SCRIPT] + command! -nargs=* -complete=customlist,TestFn TestCmd echo + func TestFn(a, b, c) + return map(range(1, 50), 'printf("a%d", v:val)') + endfunc + set wildmode=noselect,full + set wildoptions=pum + set wildmenu + set noruler + [SCRIPT] + call writefile(lines, 'XTest_pum_scroll', 'D') + let buf = RunVimInTerminal('-S XTest_pum_scroll', {'rows': 10}) + + call term_sendkeys(buf, ":TestCmd \" . repeat("\", 20)) + call TermWait(buf, 50) + call VerifyScreenDump(buf, 'Test_pum_scroll_noselect_1', {}) + + call term_sendkeys(buf, "\:TestCmd \") + call TermWait(buf, 50) + call VerifyScreenDump(buf, 'Test_pum_scroll_noselect_2', {}) + + call term_sendkeys(buf, "\") + call StopVimInTerminal(buf) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index a892dcb4a2..e87aa4ecdb 100644 --- a/src/version.c +++ b/src/version.c @@ -719,6 +719,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1521, /**/ 1520, /**/