0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.1.2288: not using all space when popup with "topleft" flips to above

Problem:    Not using all space when popup with "topleft" flips to above.
Solution:   Recompute the height when a popup flips from below to above.
            (closes #5151)
This commit is contained in:
Bram Moolenaar
2019-11-10 17:51:38 +01:00
parent 1666ac9c56
commit 5c6b6187ac
4 changed files with 21 additions and 9 deletions

View File

@@ -1102,6 +1102,7 @@ popup_adjust_position(win_T *wp)
int left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3]; int left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3];
int extra_height = top_extra + bot_extra; int extra_height = top_extra + bot_extra;
int extra_width = left_extra + right_extra; int extra_width = left_extra + right_extra;
int w_height_before_limit;
int org_winrow = wp->w_winrow; int org_winrow = wp->w_winrow;
int org_wincol = wp->w_wincol; int org_wincol = wp->w_wincol;
int org_width = wp->w_width; int org_width = wp->w_width;
@@ -1399,6 +1400,7 @@ popup_adjust_position(win_T *wp)
wp->w_height = wp->w_minheight; wp->w_height = wp->w_minheight;
if (wp->w_maxheight > 0 && wp->w_height > wp->w_maxheight) if (wp->w_maxheight > 0 && wp->w_height > wp->w_maxheight)
wp->w_height = wp->w_maxheight; wp->w_height = wp->w_maxheight;
w_height_before_limit = wp->w_height;
if (wp->w_height > Rows - wp->w_winrow) if (wp->w_height > Rows - wp->w_winrow)
wp->w_height = Rows - wp->w_winrow; wp->w_height = Rows - wp->w_winrow;
if (wp->w_height != org_height) if (wp->w_height != org_height)
@@ -1434,9 +1436,17 @@ popup_adjust_position(win_T *wp)
if (wantline + (wp->w_height + extra_height) - 1 > Rows if (wantline + (wp->w_height + extra_height) - 1 > Rows
&& wantline * 2 > Rows && wantline * 2 > Rows
&& (wp->w_popup_flags & POPF_POSINVERT)) && (wp->w_popup_flags & POPF_POSINVERT))
{
// top aligned and not enough space below but there is space above: // top aligned and not enough space below but there is space above:
// make bottom aligned // make bottom aligned and recompute the height
wp->w_height = w_height_before_limit;
wp->w_winrow = wantline - 2 - wp->w_height - extra_height; wp->w_winrow = wantline - 2 - wp->w_height - extra_height;
if (wp->w_winrow < 0)
{
wp->w_height += wp->w_winrow;
wp->w_winrow = 0;
}
}
else else
wp->w_winrow = wantline - 1; wp->w_winrow = wantline - 1;
} }

View File

@@ -1,9 +1,9 @@
|-+0&#ffffff0|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@8|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@32| @14 |-+0&#ffffff0|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@8|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@15|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@11| @14
|-|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|a@2|║|-+0#0000000#ffffff0@32| @14 |-|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|a@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@11| @14
|-|║+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|═@2|╗|-+0#0000000#ffffff0@11| @14 |-|║+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
|-|╚+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|o|n|e|║|-+0#0000000#ffffff0@11| @14 |-|╚+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
|-|@|-@5|#|-@5|%|-@5|║+0#0000001#ffd7ff255|d@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1>*|-@8| @14 |-|@|-@5|#|-@5|%|-@5|║+0#0000001#ffd7ff255|d@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|f|o|u|║|-+0#0000000#ffffff0@1>*|-@8| @14
|-@14|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|e@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|t|e@1|║|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@4| @14 |-@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
|-@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 |-@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
|-@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 |-@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
|-@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 |-@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

View File

@@ -389,9 +389,9 @@ func Test_popup_nospace()
\ border: [], \ border: [],
\ }) \ })
" cursor in a line in top half, using "topleft" with popup that " cursor in a line in top half, using "topleft" with popup that
" doesn't fit and "posinvert" set: flips to below. " doesn't fit and "posinvert" set: flips to above.
normal 8G44|r% normal 8G44|r%
let winid1 = popup_create(['one', 'two', 'tee'], #{ let winid1 = popup_create(['one', 'two', 'tee', 'fou', 'fiv'], #{
\ line: 'cursor+1', \ line: 'cursor+1',
\ col: 'cursor', \ col: 'cursor',
\ pos: 'topleft', \ pos: 'topleft',

View File

@@ -741,6 +741,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2288,
/**/ /**/
2287, 2287,
/**/ /**/