mirror of
https://github.com/vim/vim
synced 2025-07-15 08:41:54 +00:00
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 <girishji@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
af22007784
commit
0cd7f3536b
@ -411,6 +411,7 @@ cmdline_pum_create(
|
||||
// no default selection
|
||||
compl_selected = -1;
|
||||
|
||||
pum_clear();
|
||||
cmdline_pum_display();
|
||||
|
||||
return EXPAND_OK;
|
||||
|
10
src/testdir/dumps/Test_pum_scroll_noselect_1.dump
Normal file
10
src/testdir/dumps/Test_pum_scroll_noselect_1.dump
Normal file
@ -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
|
10
src/testdir/dumps/Test_pum_scroll_noselect_2.dump
Normal file
10
src/testdir/dumps/Test_pum_scroll_noselect_2.dump
Normal file
@ -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
|
@ -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
|
||||
|
@ -719,6 +719,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1521,
|
||||
/**/
|
||||
1520,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user