patch 9.1.1521: completion: pum does not reset scroll pos on reopen with 
'noselect'

Commit: 
https://github.com/vim/vim/commit/0cd7f3536bde47cf9693090b839abf88c7f019c8
Author: Girish Palya <giris...@gmail.com>
Date:   Mon Jul 7 19:47:53 2025 +0200

    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 `<C-n>`,
              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 <giris...@gmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index 13d540e77..d5730ab6b 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 000000000..8e45c8a58
--- /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 000000000..24d8ca84c
--- /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 c5a7d85c7..6aedf3ec2 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 \<tab>" . repeat("\<c-n>", 20))
+  call TermWait(buf, 50)
+  call VerifyScreenDump(buf, 'Test_pum_scroll_noselect_1', {})
+
+  call term_sendkeys(buf, "\<esc>:TestCmd \<tab>")
+  call TermWait(buf, 50)
+  call VerifyScreenDump(buf, 'Test_pum_scroll_noselect_2', {})
+
+  call term_sendkeys(buf, "\<esc>")
+  call StopVimInTerminal(buf)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index a892dcb4a..e87aa4ecd 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,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1uYq8K-009779-QY%40256bit.org.

Raspunde prin e-mail lui