summaryrefslogtreecommitdiff
path: root/src/popupwin.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-10-24 19:25:00 +0200
committerBram Moolenaar <Bram@vim.org>2019-10-24 19:25:00 +0200
commitb754b5bf6d9ac1f3654552973aa6f9c11239af3d (patch)
tree08eb80774c9357cb9fd603b5cc185a35fa534623 /src/popupwin.c
parentec6f7350129f8c7809fd061f58a9eb6790c445a8 (diff)
downloadvim-git-b754b5bf6d9ac1f3654552973aa6f9c11239af3d.tar.gz
patch 8.1.2210: using negative offset for popup_create() does not workv8.1.2210
Problem: Using negative offset for popup_create() does not work. Solution: Use -1 instead of zero. (closes #5111)
Diffstat (limited to 'src/popupwin.c')
-rw-r--r--src/popupwin.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/popupwin.c b/src/popupwin.c
index a9579320e..a53ae0f66 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -71,8 +71,9 @@ popup_options_one(dict_T *dict, char_u *key)
else // "col"
n = screen_screencol() + 1 + n;
- if (n < 1)
- n = 1;
+ // Zero means "not set", use -1 instead.
+ if (n == 0)
+ n = -1;
return n;
}
@@ -222,7 +223,7 @@ popup_start_drag(win_T *wp, int row, int col)
{
drag_start_row = mouse_row;
drag_start_col = mouse_col;
- if (wp->w_wantline == 0)
+ if (wp->w_wantline <= 0)
drag_start_wantline = wp->w_winrow + 1;
else
drag_start_wantline = wp->w_wantline;
@@ -1081,7 +1082,9 @@ popup_adjust_position(win_T *wp)
int org_leftoff = wp->w_popup_leftoff;
int minwidth;
int wantline = wp->w_wantline; // adjusted for textprop
+ int use_wantline = wantline != 0;
int wantcol = wp->w_wantcol; // adjusted for textprop
+ int use_wantcol = wantcol != 0;
wp->w_winrow = 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 (wantline == 0)
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))
{
@@ -1161,7 +1169,7 @@ popup_adjust_position(win_T *wp)
}
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_winrow = wantline - 1;
@@ -1169,7 +1177,7 @@ popup_adjust_position(win_T *wp)
wp->w_winrow = Rows - 1;
}
- if (wantcol == 0)
+ if (!use_wantcol)
center_hor = TRUE;
else if (wantcol > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT
|| wp->w_popup_pos == POPPOS_BOTLEFT))
@@ -1372,8 +1380,8 @@ popup_adjust_position(win_T *wp)
// bottom aligned: may move down
wp->w_winrow = wantline - (wp->w_height + extra_height);
else
- // not enough space, make top aligned
- wp->w_winrow = wantline + 1;
+ // Not enough space, make top aligned.
+ wp->w_winrow = (wantline < 0 ? 0 : wantline) + 1;
}
if (wp->w_winrow >= Rows)
wp->w_winrow = Rows - 1;