Skip to content

Commit bf61fdd

Browse files
committed
patch 8.2.1414: popupwindow missing last couple of lines
Problem: Popupwindow missing last couple of lines when cursor is in the first line. Solution: Compute the max height also when top aligned. (closes #6664)
1 parent 94f4ffa commit bf61fdd

5 files changed

Lines changed: 45 additions & 18 deletions

File tree

src/popupwin.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ popup_adjust_position(win_T *wp)
11341134
int wantline = wp->w_wantline; // adjusted for textprop
11351135
int wantcol = wp->w_wantcol; // adjusted for textprop
11361136
int use_wantcol = wantcol != 0;
1137+
int adjust_height_for_top_aligned = FALSE;
11371138

11381139
wp->w_winrow = 0;
11391140
wp->w_wincol = 0;
@@ -1483,16 +1484,7 @@ popup_adjust_position(win_T *wp)
14831484
// Not enough space and more space on the other side: make top
14841485
// aligned.
14851486
wp->w_winrow = (wantline < 0 ? 0 : wantline) + 1;
1486-
if (wp->w_winrow + wp->w_height + extra_height >= Rows)
1487-
{
1488-
wp->w_height = Rows - wp->w_winrow - extra_height;
1489-
if (wp->w_want_scrollbar
1490-
#ifdef FEAT_TERMINAL
1491-
&& wp->w_buffer->b_term == NULL
1492-
#endif
1493-
)
1494-
wp->w_has_scrollbar = TRUE;
1495-
}
1487+
adjust_height_for_top_aligned = TRUE;
14961488
}
14971489
}
14981490
else if (wp->w_popup_pos == POPPOS_TOPRIGHT
@@ -1513,9 +1505,25 @@ popup_adjust_position(win_T *wp)
15131505
}
15141506
}
15151507
else
1508+
{
15161509
wp->w_winrow = wantline - 1;
1510+
adjust_height_for_top_aligned = TRUE;
1511+
}
15171512
}
1518-
// make sure w_window is valid
1513+
1514+
if (adjust_height_for_top_aligned && wp->w_want_scrollbar
1515+
&& wp->w_winrow + wp->w_height + extra_height > Rows)
1516+
{
1517+
// Bottom of the popup goes below the last line, reduce the height and
1518+
// add a scrollbar.
1519+
wp->w_height = Rows - wp->w_winrow - extra_height;
1520+
#ifdef FEAT_TERMINAL
1521+
if (wp->w_buffer->b_term == NULL)
1522+
#endif
1523+
wp->w_has_scrollbar = TRUE;
1524+
}
1525+
1526+
// make sure w_winrow is valid
15191527
if (wp->w_winrow >= Rows)
15201528
wp->w_winrow = Rows - 1;
15211529
else if (wp->w_winrow < 0)

src/testdir/dumps/Test_popupwin_nospace.dump

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
|-|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|b@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@11| @14
44
|-|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|c@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|t|e@1|║|-+0#0000000#ffffff0@11| @14
55
|-|@|-@5|#|-@5|%|-@5|║+0#0000001#ffd7ff255|d@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|f|o|u|║|-+0#0000000#ffffff0@1>*|-@8| @14
6-
|-@14|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|e@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|f|i|v|║|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@4| @14
7-
|-@14|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@15|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|a@2||-+0#0000000#ffffff0@4| @14
8-
|-@14|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1|*|-@5|@|-@5|#|-@5|%|-@5|║+0#0000001#ffd7ff255|b@2||-+0#0000000#ffffff0@4| @14
9-
|-@14|║+0#0000001#ffd7ff255|t|e@1|║|-+0#0000000#ffffff0@8|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|c@2||-+0#0000000#ffffff0@4| @14
10-
|-@14|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|o|n|e||-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|d@2||-+0#0000000#ffffff0@4| @14
11-
|-@28|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|t|w|o||-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|e@2||-+0#0000000#ffffff0@4| @14
12-
@29|╚+0#0000001#ffd7ff255|═@2|╝| +0#0000000#ffffff0@1|+0#0000001#ffd7ff255|t|e@1|║| +0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|f@2|║| +0#0000000#ffffff0@1|5|,|5|1| @9|T|o|p|
6+
|-@14|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|e@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|f|i|v|║|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@3|╗|-+0#0000000#ffffff0@3| @14
7+
|-@14|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@15|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|a@2| +0#0000000#0000001|║+0#0000001#ffd7ff255|-+0#0000000#ffffff0@3| @14
8+
|-@14|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1|*|-@5|@|-@5|#|-@5|%|-@5|║+0#0000001#ffd7ff255|b@2| +0#0000000#0000001|║+0#0000001#ffd7ff255|-+0#0000000#ffffff0@3| @14
9+
|-@14|║+0#0000001#ffd7ff255|t|e@1|║|-+0#0000000#ffffff0@8|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@3|╗|-+0#0000000#ffffff0@7|║+0#0000001#ffd7ff255|c@2| +0#0000000#0000001|║+0#0000001#ffd7ff255|-+0#0000000#ffffff0@3| @14
10+
|-@14|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|o|n|e| +0#0000000#0000001|║+0#0000001#ffd7ff255|-+0#0000000#ffffff0@7|║+0#0000001#ffd7ff255|d@2| +0#0000000#0000001|║+0#0000001#ffd7ff255|-+0#0000000#ffffff0@3| @14
11+
|-@28|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|t|w|o| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255|-+0#0000000#ffffff0@7|║+0#0000001#ffd7ff255|e@2| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255|-+0#0000000#ffffff0@3| @14
12+
@29|╚+0#0000001#ffd7ff255|═@2|╝| +0#0000000#ffffff0@1|+0#0000001#ffd7ff255|═@3|╝| +0#0000000#ffffff0@7|╚+0#0000001#ffd7ff255|═@3|╝| +0#0000000#ffffff0|5|,|5|1| @9|T|o|p|
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
|1+0&#ffffff0@8>1| @64
2+
|2@8|╔+0#0000001#ffd7ff255|═@8|╗| +0#0000000#ffffff0@54
3+
|3@8|║+0#0000001#ffd7ff255|o|n|e| @4| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@54
4+
|4@8|║+0#0000001#ffd7ff255|t|w|o| @4| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@54
5+
|5@8|║+0#0000001#ffd7ff255|t|h|r|e@1| @2| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@54
6+
|6@8|║+0#0000001#ffd7ff255|f|o|u|r| @3| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@54
7+
|7@8|║+0#0000001#ffd7ff255|f|i|v|e| @3| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@54
8+
|8@8|║+0#0000001#ffd7ff255|s|i|x| @4| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@54
9+
|9@8|║+0#0000001#ffd7ff255|s|e|v|e|n| @2| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@54
10+
|:|c|a|l@1| |S|h|o|╚+0#0000001#ffd7ff255|═@8|╝| +0#0000000#ffffff0@36|1|,|1|0| @9|T|o|p|

src/testdir/test_popupwin.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ func Test_popup_with_mask()
753753
\ posinvert: 0,
754754
\ wrap: 0,
755755
\ fixed: 1,
756+
\ scrollbar: v:false,
756757
\ zindex: 90,
757758
\ padding: [],
758759
\ highlight: 'PopupColor',
@@ -772,6 +773,7 @@ func Test_popup_with_mask()
772773
\ posinvert: 0,
773774
\ wrap: 0,
774775
\ fixed: 1,
776+
\ scrollbar: v:false,
775777
\ close: 'button',
776778
\ zindex: 90,
777779
\ padding: [],
@@ -2169,6 +2171,11 @@ func Test_popup_too_high_scrollbar()
21692171
call term_sendkeys(buf, ":call ShowPopup()\<CR>")
21702172
call VerifyScreenDump(buf, 'Test_popupwin_toohigh_2', {})
21712173

2174+
call term_sendkeys(buf, ":call popup_clear()\<CR>")
2175+
call term_sendkeys(buf, "gg$")
2176+
call term_sendkeys(buf, ":call ShowPopup()\<CR>")
2177+
call VerifyScreenDump(buf, 'Test_popupwin_toohigh_3', {})
2178+
21722179
" clean up
21732180
call StopVimInTerminal(buf)
21742181
call delete('XtestPopupToohigh')

src/version.c

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

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1414,
757759
/**/
758760
1413,
759761
/**/

0 commit comments

Comments
 (0)