]> granicus.if.org Git - vim/commitdiff
patch 8.2.4799: popup does not use correct topline v8.2.4799
authorLemonBoy <thatlemon@gmail.com>
Wed, 20 Apr 2022 18:47:37 +0000 (19:47 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 20 Apr 2022 18:47:37 +0000 (19:47 +0100)
Problem:    Popup does not use correct topline.
Solution:   Also add one when firstline is negative. (closes #10229)

src/popupwin.c
src/testdir/test_popupwin.vim
src/version.c

index e6792c8528f22b21ca50e4228e845c11d615fded..27e9fe12e6d601d4799c9b581f7a9d4e1ff9f9ac 100644 (file)
@@ -1414,7 +1414,7 @@ popup_adjust_position(win_T *wp)
     }
 
     if (wp->w_firstline < 0)
-       wp->w_topline = lnum > 0 ? lnum + 1 : lnum;
+       wp->w_topline = lnum + 1;
 
     wp->w_has_scrollbar = wp->w_want_scrollbar
           && (wp->w_topline > 1 || lnum <= wp->w_buffer->b_ml.ml_line_count);
index b91689e50ca47666bf089c0453a92e3e6020202b..3e5373ca86abc9f238a1a50f7883bc2d0d8a6e05 100644 (file)
@@ -514,6 +514,19 @@ func Test_popup_firstline()
   call assert_equal(5, popup_getpos(winid).firstline)
 
   call popup_close(winid)
+
+  " Popup with less elements than the maximum height and negative firstline:
+  " check that the popup height is correctly computed.
+  let winid = popup_create(['xxx']->repeat(4), #{
+        \ firstline: -1,
+        \ maxheight: 6,
+       \ })
+
+  let pos = popup_getpos(winid)
+  call assert_equal(3, pos.width)
+  call assert_equal(4, pos.height)
+
+  call popup_close(winid)
 endfunc
 
 func Test_popup_firstline_cursorline()
index 83d8e1b4958a05b685bfe1646adf5a5224fa54df..447bbd88072ea2185faae54bb5286d77bb09b04a 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4799,
 /**/
     4798,
 /**/