Skip to content

Commit 30efcf3

Browse files
committed
patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Problem: CTRL-U and CTRL-D don't work in popup window. Solution: Initialize 'scroll'. Add "lastline" in popup_getpos(). (closes #5170)
1 parent d047840 commit 30efcf3

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

runtime/doc/popup.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*popup.txt* For Vim version 8.1. Last change: 2019 Oct 20
1+
*popup.txt* For Vim version 8.1. Last change: 2019 Nov 03
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -362,6 +362,7 @@ popup_getpos({id}) *popup_getpos()*
362362
core_height height of the text box in screen cells
363363
firstline line of the buffer at top (1 unless scrolled)
364364
(not the value of the "firstline" property)
365+
lastline line of the buffer at the bottom
365366
scrollbar non-zero if a scrollbar is displayed
366367
visible one if the popup is displayed, zero if hidden
367368
Note that these are the actual screen positions. They differ

src/popupwin.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,8 @@ popup_adjust_position(win_T *wp)
13731373
wp->w_height = wp->w_maxheight;
13741374
if (wp->w_height > Rows - wp->w_winrow)
13751375
wp->w_height = Rows - wp->w_winrow;
1376+
if (wp->w_height != org_height)
1377+
win_comp_scroll(wp);
13761378

13771379
if (center_vert)
13781380
{
@@ -2500,6 +2502,7 @@ f_popup_getpos(typval_T *argvars, typval_T *rettv)
25002502

25012503
dict_add_number(dict, "scrollbar", wp->w_has_scrollbar);
25022504
dict_add_number(dict, "firstline", wp->w_topline);
2505+
dict_add_number(dict, "lastline", wp->w_botline - 1);
25032506
dict_add_number(dict, "visible",
25042507
win_valid(wp) && (wp->w_popup_flags & POPF_HIDDEN) == 0);
25052508

src/testdir/test_popupwin.vim

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ func Test_popup_with_border_and_padding()
142142
\ height: 3,
143143
\ core_height: 1,
144144
\ firstline: 1,
145+
\ lastline: 1,
145146
\ scrollbar: 0,
146147
\ visible: 1}
147148
let winid = popup_create('hello border', #{line: 2, col: 3, border: []})",
@@ -186,6 +187,7 @@ func Test_popup_with_border_and_padding()
186187
\ scrollbar: 0,
187188
\ core_height: 1,
188189
\ firstline: 1,
190+
\ lastline: 1,
189191
\ visible: 1}, popup_getpos(winid))
190192

191193
call popup_clear()
@@ -385,6 +387,24 @@ func Test_popup_firstline()
385387
call assert_equal(0, popup_getoptions(winid).firstline)
386388
call assert_equal(10, popup_getpos(winid).firstline)
387389

390+
" CTRL-D scrolls down half a page
391+
let winid = popup_create(['xxx']->repeat(50), #{
392+
\ maxheight: 8,
393+
\ })
394+
redraw
395+
call assert_equal(1, popup_getpos(winid).firstline)
396+
call win_execute(winid, "normal! \<C-D>")
397+
call assert_equal(5, popup_getpos(winid).firstline)
398+
call win_execute(winid, "normal! \<C-D>")
399+
call assert_equal(9, popup_getpos(winid).firstline)
400+
call win_execute(winid, "normal! \<C-U>")
401+
call assert_equal(5, popup_getpos(winid).firstline)
402+
403+
call win_execute(winid, "normal! \<C-F>")
404+
call assert_equal(11, popup_getpos(winid).firstline)
405+
call win_execute(winid, "normal! \<C-B>")
406+
call assert_equal(5, popup_getpos(winid).firstline)
407+
388408
call popup_close(winid)
389409
endfunc
390410

@@ -1795,6 +1815,7 @@ func Test_popup_scrollbar()
17951815
\ minheight: 4,
17961816
\ maxheight: 4,
17971817
\ firstline: 1,
1818+
\ lastline: 4,
17981819
\ wrap: v:true,
17991820
\ scrollbar: v:true,
18001821
\ mapping: v:false,

src/version.c

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

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
2250,
744746
/**/
745747
2249,
746748
/**/

0 commit comments

Comments
 (0)