]> granicus.if.org Git - vim/commitdiff
patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window v8.1.2250
authorBram Moolenaar <Bram@vim.org>
Sun, 3 Nov 2019 21:29:38 +0000 (22:29 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 3 Nov 2019 21:29:38 +0000 (22:29 +0100)
Problem:    CTRL-U and CTRL-D don't work in popup window.
Solution:   Initialize 'scroll'.  Add "lastline" in popup_getpos().
            (closes #5170)

runtime/doc/popup.txt
src/popupwin.c
src/testdir/test_popupwin.vim
src/version.c

index 2ac54b638cb644d7fc1a7b02a5f78ea6f7aa471b..fc00ecffcdbc1e29e639992502113e8125fab742 100644 (file)
@@ -1,4 +1,4 @@
-*popup.txt*  For Vim version 8.1.  Last change: 2019 Oct 20
+*popup.txt*  For Vim version 8.1.  Last change: 2019 Nov 03
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -362,6 +362,7 @@ popup_getpos({id})                                  *popup_getpos()*
                    core_height height of the text box in screen cells
                    firstline   line of the buffer at top (1 unless scrolled)
                                (not the value of the "firstline" property)
+                   lastline    line of the buffer at the bottom
                    scrollbar   non-zero if a scrollbar is displayed
                    visible     one if the popup is displayed, zero if hidden
                Note that these are the actual screen positions.  They differ
index d6e6207608c11bbba91e02230599ddeb4fffdcfd..ddb1254d1b4a3f75f13525fe7fe5754a0381c2c1 100644 (file)
@@ -1373,6 +1373,8 @@ popup_adjust_position(win_T *wp)
        wp->w_height = wp->w_maxheight;
     if (wp->w_height > Rows - wp->w_winrow)
        wp->w_height = Rows - wp->w_winrow;
+    if (wp->w_height != org_height)
+       win_comp_scroll(wp);
 
     if (center_vert)
     {
@@ -2500,6 +2502,7 @@ f_popup_getpos(typval_T *argvars, typval_T *rettv)
 
        dict_add_number(dict, "scrollbar", wp->w_has_scrollbar);
        dict_add_number(dict, "firstline", wp->w_topline);
+       dict_add_number(dict, "lastline", wp->w_botline - 1);
        dict_add_number(dict, "visible",
                      win_valid(wp) && (wp->w_popup_flags & POPF_HIDDEN) == 0);
 
index 2c4da0b794c67ee0437ac89ac6756d5b6ea1f853..e38b7211e0881717170f7f7f97fb08f580d680aa 100644 (file)
@@ -142,6 +142,7 @@ func Test_popup_with_border_and_padding()
        \ height: 3,
        \ core_height: 1,
        \ firstline: 1,
+       \ lastline: 1,
        \ scrollbar: 0,
        \ visible: 1}
   let winid = popup_create('hello border', #{line: 2, col: 3, border: []})",
@@ -186,6 +187,7 @@ func Test_popup_with_border_and_padding()
        \ scrollbar: 0,
        \ core_height: 1,
        \ firstline: 1,
+       \ lastline: 1,
        \ visible: 1}, popup_getpos(winid))
 
   call popup_clear()
@@ -385,6 +387,24 @@ func Test_popup_firstline()
   call assert_equal(0, popup_getoptions(winid).firstline)
   call assert_equal(10, popup_getpos(winid).firstline)
 
+  " CTRL-D scrolls down half a page
+  let winid = popup_create(['xxx']->repeat(50), #{
+       \ maxheight: 8,
+       \ })
+  redraw
+  call assert_equal(1, popup_getpos(winid).firstline)
+  call win_execute(winid, "normal! \<C-D>")
+  call assert_equal(5, popup_getpos(winid).firstline)
+  call win_execute(winid, "normal! \<C-D>")
+  call assert_equal(9, popup_getpos(winid).firstline)
+  call win_execute(winid, "normal! \<C-U>")
+  call assert_equal(5, popup_getpos(winid).firstline)
+
+  call win_execute(winid, "normal! \<C-F>")
+  call assert_equal(11, popup_getpos(winid).firstline)
+  call win_execute(winid, "normal! \<C-B>")
+  call assert_equal(5, popup_getpos(winid).firstline)
+
   call popup_close(winid)
 endfunc
 
@@ -1795,6 +1815,7 @@ func Test_popup_scrollbar()
            \ minheight: 4,
            \ maxheight: 4,
            \ firstline: 1,
+           \ lastline: 4,
            \ wrap: v:true,
            \ scrollbar: v:true,
            \ mapping: v:false,
index 0418204a5b2c9025349d90844b0bc1e94260e9ac..5a4a1e48513cfdd66b6e3ebf913a0f84aa010a71 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2250,
 /**/
     2249,
 /**/