]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1147: preview-window does not scroll correctly v9.1.1147
authorGirish Palya <girishji@gmail.com>
Mon, 24 Feb 2025 20:39:42 +0000 (21:39 +0100)
committerChristian Brabandt <cb@256bit.org>
Mon, 24 Feb 2025 20:39:42 +0000 (21:39 +0100)
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>
src/popupmenu.c
src/testdir/test_ins_complete.vim
src/version.c

index d9ab997bf42f294c5c20412153ed3a72a6f302fe..44235efbd7dc7fc70f9c57f87a7052bbe20e9ce4 100644 (file)
@@ -1097,7 +1097,7 @@ pum_set_selected(int n, int repeat UNUSED)
                    if (pum_selected != prev_selected)
                    {
 # ifdef FEAT_PROP_POPUP
-                       curwin->w_firstline = 1;
+                       curwin->w_firstline = 0;
 # endif
                        curwin->w_topline = 1;
                    }
index c34f6426e05a12c01bf110c28760d862e07b0510..b302a3ee745e7b03f30b49fed59fd59b6820df3d 100644 (file)
@@ -497,6 +497,52 @@ 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! \<PageDown>")
+  return ''
+endfunc
+
+func ScrollInfoWindowPageUp()
+  call win_execute(popup_findinfo(), "normal! \<PageUp>")
+  return ''
+endfunc
+
+func ScrollInfoWindowTest(mvmt, count, fline)
+  new
+  set completeopt=menuone,popup,noinsert,noselect
+  set completepopup=height:5
+  set completefunc=ScrollInfoWindowUserDefinedFn
+  let keyseq = "i\<C-X>\<C-U>\<C-N>"
+  for _ in range(a:count)
+    let keyseq .= (a:mvmt == "pageup" ? "\<C-R>\<C-R>=ScrollInfoWindowPageUp()\<CR>" :
+          \ "\<C-R>\<C-R>=ScrollInfoWindowPageDown()\<CR>")
+  endfor
+  let keyseq .= "\<C-R>\<C-R>=string(popup_getpos(popup_findinfo()))\<CR>\<ESC>"
+  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()
+  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
index 1d362718beac100a5005acb639820b4465ec549b..d028159f6777df8f1c2b6d0a76169e3e8710283e 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1147,
 /**/
     1146,
 /**/