Skip to content

Commit 12b1eb5

Browse files
girishjichrisbra
authored andcommitted
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! \<PageDown>") 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: #16703 Signed-off-by: Girish Palya <girishji@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent f877040 commit 12b1eb5

3 files changed

Lines changed: 49 additions & 1 deletion

File tree

src/popupmenu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ pum_set_selected(int n, int repeat UNUSED)
10971097
if (pum_selected != prev_selected)
10981098
{
10991099
# ifdef FEAT_PROP_POPUP
1100-
curwin->w_firstline = 1;
1100+
curwin->w_firstline = 0;
11011101
# endif
11021102
curwin->w_topline = 1;
11031103
}

src/testdir/test_ins_complete.vim

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,52 @@ func Test_completefunc_info()
497497
set completefunc&
498498
endfunc
499499

500+
func ScrollInfoWindowUserDefinedFn(findstart, query)
501+
" User defined function (i_CTRL-X_CTRL-U)
502+
if a:findstart
503+
return col('.')
504+
endif
505+
let infostr = range(20)->mapnew({_, v -> string(v)})->join("\n")
506+
return [{'word': 'foo', 'info': infostr}, {'word': 'bar'}]
507+
endfunc
508+
509+
func ScrollInfoWindowPageDown()
510+
call win_execute(popup_findinfo(), "normal! \<PageDown>")
511+
return ''
512+
endfunc
513+
514+
func ScrollInfoWindowPageUp()
515+
call win_execute(popup_findinfo(), "normal! \<PageUp>")
516+
return ''
517+
endfunc
518+
519+
func ScrollInfoWindowTest(mvmt, count, fline)
520+
new
521+
set completeopt=menuone,popup,noinsert,noselect
522+
set completepopup=height:5
523+
set completefunc=ScrollInfoWindowUserDefinedFn
524+
let keyseq = "i\<C-X>\<C-U>\<C-N>"
525+
for _ in range(a:count)
526+
let keyseq .= (a:mvmt == "pageup" ? "\<C-R>\<C-R>=ScrollInfoWindowPageUp()\<CR>" :
527+
\ "\<C-R>\<C-R>=ScrollInfoWindowPageDown()\<CR>")
528+
endfor
529+
let keyseq .= "\<C-R>\<C-R>=string(popup_getpos(popup_findinfo()))\<CR>\<ESC>"
530+
call feedkeys(keyseq, "tx")
531+
call assert_match('''firstline'': ' . a:fline, getline(1))
532+
bwipe!
533+
set completeopt&
534+
set completepopup&
535+
set completefunc&
536+
endfunc
537+
538+
func Test_scroll_info_window()
539+
call ScrollInfoWindowTest("", 0, 1)
540+
call ScrollInfoWindowTest("pagedown", 1, 4)
541+
call ScrollInfoWindowTest("pagedown", 2, 7)
542+
call ScrollInfoWindowTest("pagedown", 3, 11)
543+
call ScrollInfoWindowTest("pageup", 3, 1)
544+
endfunc
545+
500546
func CompleteInfoUserDefinedFn(findstart, query)
501547
" User defined function (i_CTRL-X_CTRL-U)
502548
if a:findstart

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
1147,
707709
/**/
708710
1146,
709711
/**/

0 commit comments

Comments
 (0)