0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.1.2210: using negative offset for popup_create() does not work

Problem:    Using negative offset for popup_create() does not work.
Solution:   Use -1 instead of zero. (closes #5111)
This commit is contained in:
Bram Moolenaar
2019-10-24 19:25:00 +02:00
parent ec6f735012
commit b754b5bf6d
4 changed files with 38 additions and 20 deletions

View File

@@ -71,8 +71,9 @@ popup_options_one(dict_T *dict, char_u *key)
else // "col" else // "col"
n = screen_screencol() + 1 + n; n = screen_screencol() + 1 + n;
if (n < 1) // Zero means "not set", use -1 instead.
n = 1; if (n == 0)
n = -1;
return n; return n;
} }
@@ -222,7 +223,7 @@ popup_start_drag(win_T *wp, int row, int col)
{ {
drag_start_row = mouse_row; drag_start_row = mouse_row;
drag_start_col = mouse_col; drag_start_col = mouse_col;
if (wp->w_wantline == 0) if (wp->w_wantline <= 0)
drag_start_wantline = wp->w_winrow + 1; drag_start_wantline = wp->w_winrow + 1;
else else
drag_start_wantline = wp->w_wantline; drag_start_wantline = wp->w_wantline;
@@ -1081,7 +1082,9 @@ popup_adjust_position(win_T *wp)
int org_leftoff = wp->w_popup_leftoff; int org_leftoff = wp->w_popup_leftoff;
int minwidth; int minwidth;
int wantline = wp->w_wantline; // adjusted for textprop int wantline = wp->w_wantline; // adjusted for textprop
int use_wantline = wantline != 0;
int wantcol = wp->w_wantcol; // adjusted for textprop int wantcol = wp->w_wantcol; // adjusted for textprop
int use_wantcol = wantcol != 0;
wp->w_winrow = 0; wp->w_winrow = 0;
wp->w_wincol = 0; wp->w_wincol = 0;
@@ -1097,6 +1100,11 @@ popup_adjust_position(win_T *wp)
// If no line was specified default to vertical centering. // If no line was specified default to vertical centering.
if (wantline == 0) if (wantline == 0)
center_vert = TRUE; center_vert = TRUE;
else if (wantline < 0)
// If "wantline" is negative it actually means zero.
wantline = 0;
if (wantcol < 0)
wantcol = 0;
if (wp->w_popup_prop_type > 0 && win_valid(wp->w_popup_prop_win)) if (wp->w_popup_prop_type > 0 && win_valid(wp->w_popup_prop_win))
{ {
@@ -1161,7 +1169,7 @@ popup_adjust_position(win_T *wp)
} }
else else
{ {
if (wantline > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT if (use_wantline && (wp->w_popup_pos == POPPOS_TOPLEFT
|| wp->w_popup_pos == POPPOS_TOPRIGHT)) || wp->w_popup_pos == POPPOS_TOPRIGHT))
{ {
wp->w_winrow = wantline - 1; wp->w_winrow = wantline - 1;
@@ -1169,7 +1177,7 @@ popup_adjust_position(win_T *wp)
wp->w_winrow = Rows - 1; wp->w_winrow = Rows - 1;
} }
if (wantcol == 0) if (!use_wantcol)
center_hor = TRUE; center_hor = TRUE;
else if (wantcol > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT else if (wantcol > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT
|| wp->w_popup_pos == POPPOS_BOTLEFT)) || wp->w_popup_pos == POPPOS_BOTLEFT))
@@ -1372,8 +1380,8 @@ popup_adjust_position(win_T *wp)
// bottom aligned: may move down // bottom aligned: may move down
wp->w_winrow = wantline - (wp->w_height + extra_height); wp->w_winrow = wantline - (wp->w_height + extra_height);
else else
// not enough space, make top aligned // Not enough space, make top aligned.
wp->w_winrow = wantline + 1; wp->w_winrow = (wantline < 0 ? 0 : wantline) + 1;
} }
if (wp->w_winrow >= Rows) if (wp->w_winrow >= Rows)
wp->w_winrow = Rows - 1; wp->w_winrow = Rows - 1;

View File

@@ -1,12 +1,12 @@
|-+0&#ffffff0@59| @14 |-+0&#ffffff0@49>*|-@8| @14
|-@1|#|-@20|@|-@34| @14 |-@1|#|-@19|@|-@25|╔+0#0000001#ffd7ff255|═@4|╗|-+0#0000000#ffffff0@2| @14
|-@1|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@2|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@2|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@2|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@8| @14 |-@1|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @4|║|-+0#0000000#ffffff0@2| @14
|-@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@8| @14 |-@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |o|n|e| |║|-+0#0000000#ffffff0@2| @14
|-@1|║+0#0000001#ffd7ff255| |f|i|r|s|t| @1|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |F|i|r|s|t| @1|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |f|i|R|S|t| @1|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |F|I|r|s|T| @1|║|-+0#0000000#ffffff0@8| @14 |-@1|║+0#0000001#ffd7ff255| |f|i|r|s|t| @1|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |F|i|r|s|t| @1|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |f|i|R|S|t| @1|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |F|I|r|s|T| @1|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |t|w|o| |║|-+0#0000000#ffffff0@2| @14
|-@1|║+0#0000001#ffd7ff255| |s|e|c|o|n|d| |║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |S|e|c|o|n|D| |║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |s|e|C|O|n|d| |║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |S|E|c|o|N|D| |║|-+0#0000000#ffffff0@8| @14 |-@1|║+0#0000001#ffd7ff255| |s|e|c|o|n|d| |║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |S|e|c|o|n|D| |║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |s|e|C|O|n|d| |║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| |S|E|c|o|N|D| |║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @4|║|-+0#0000000#ffffff0@2| @14
|-@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@8| @14 |-@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@4|╝|-+0#0000000#ffffff0@2| @14
|-@1|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@2|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@2|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@2|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@8| @14 |-@1|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@11| @14
|-@27|%|-@20>&|-@8| @14 |-@25|%|-@19|&|-@11| @14
|-@59| @14 |-@59| @14
|-@59| @14 |-@59| @14
@57|9|,|5|1| @9|T|o|p| @57|1|,|5|1| @9|T|o|p|

View File

@@ -278,7 +278,7 @@ func Test_popup_all_corners()
\ border: [], \ border: [],
\ padding: [], \ padding: [],
\ }) \ })
normal 25|r@ normal 24|r@
let winid1 = popup_create(['First', 'SeconD'], #{ let winid1 = popup_create(['First', 'SeconD'], #{
\ line: 'cursor+1', \ line: 'cursor+1',
\ col: 'cursor', \ col: 'cursor',
@@ -286,7 +286,7 @@ func Test_popup_all_corners()
\ border: [], \ border: [],
\ padding: [], \ padding: [],
\ }) \ })
normal 9G29|r% normal 9G27|r%
let winid1 = popup_create(['fiRSt', 'seCOnd'], #{ let winid1 = popup_create(['fiRSt', 'seCOnd'], #{
\ line: 'cursor-1', \ line: 'cursor-1',
\ col: 'cursor', \ col: 'cursor',
@@ -294,7 +294,7 @@ func Test_popup_all_corners()
\ border: [], \ border: [],
\ padding: [], \ padding: [],
\ }) \ })
normal 51|r& normal 48|r&
let winid1 = popup_create(['FIrsT', 'SEcoND'], #{ let winid1 = popup_create(['FIrsT', 'SEcoND'], #{
\ line: 'cursor-1', \ line: 'cursor-1',
\ col: 'cursor', \ col: 'cursor',
@@ -302,6 +302,14 @@ func Test_popup_all_corners()
\ border: [], \ border: [],
\ padding: [], \ padding: [],
\ }) \ })
normal 1G51|r*
let winid1 = popup_create(['one', 'two'], #{
\ line: 'cursor-1',
\ col: 'cursor',
\ pos: 'botleft',
\ border: [],
\ padding: [],
\ })
END END
call writefile(lines, 'XtestPopupCorners') call writefile(lines, 'XtestPopupCorners')
let buf = RunVimInTerminal('-S XtestPopupCorners', #{rows: 12}) let buf = RunVimInTerminal('-S XtestPopupCorners', #{rows: 12})

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 */
/**/
2210,
/**/ /**/
2209, 2209,
/**/ /**/