0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.1.1602: popup window cannot overflow on the left or right

Problem:    Popup window cannot overflow on the left or right.
Solution:   Only set the "fixed" option when it is in the dict. Set w_leftcol
            to allow for the popup overflowing on the left and use it when
            applying the mask.
This commit is contained in:
Bram Moolenaar 2019-06-28 04:06:50 +02:00
parent 8da4181631
commit 711d02c96d
2 changed files with 30 additions and 4 deletions

View File

@ -78,6 +78,7 @@ get_pos_options(win_T *wp, dict_T *dict)
{ {
char_u *str; char_u *str;
int nr; int nr;
dictitem_T *di;
nr = popup_options_one(dict, (char_u *)"line"); nr = popup_options_one(dict, (char_u *)"line");
if (nr > 0) if (nr > 0)
@ -86,6 +87,8 @@ get_pos_options(win_T *wp, dict_T *dict)
if (nr > 0) if (nr > 0)
wp->w_wantcol = nr; wp->w_wantcol = nr;
di = dict_find(dict, (char_u *)"fixed", -1);
if (di != NULL)
wp->w_popup_fixed = dict_get_number(dict, (char_u *)"fixed") != 0; wp->w_popup_fixed = dict_get_number(dict, (char_u *)"fixed") != 0;
str = dict_get_string(dict, (char_u *)"pos", FALSE); str = dict_get_string(dict, (char_u *)"pos", FALSE);
@ -666,10 +669,12 @@ popup_adjust_position(win_T *wp)
int org_wincol = wp->w_wincol; int org_wincol = wp->w_wincol;
int org_width = wp->w_width; int org_width = wp->w_width;
int org_height = wp->w_height; int org_height = wp->w_height;
int org_leftcol = wp->w_leftcol;
int minwidth; int minwidth;
wp->w_winrow = 0; wp->w_winrow = 0;
wp->w_wincol = 0; wp->w_wincol = 0;
wp->w_leftcol = 0;
if (wp->w_popup_pos == POPPOS_CENTER) if (wp->w_popup_pos == POPPOS_CENTER)
{ {
// center after computing the size // center after computing the size
@ -785,10 +790,21 @@ popup_adjust_position(win_T *wp)
else if (wp->w_popup_pos == POPPOS_BOTRIGHT else if (wp->w_popup_pos == POPPOS_BOTRIGHT
|| wp->w_popup_pos == POPPOS_TOPRIGHT) || wp->w_popup_pos == POPPOS_TOPRIGHT)
{ {
int leftoff = wp->w_wantcol - (wp->w_width + extra_width);
// Right aligned: move to the right if needed. // Right aligned: move to the right if needed.
// No truncation, because that would change the height. // No truncation, because that would change the height.
if (wp->w_width + extra_width < wp->w_wantcol) if (leftoff >= 0)
wp->w_wincol = wp->w_wantcol - (wp->w_width + extra_width); wp->w_wincol = leftoff;
else if (wp->w_popup_fixed)
{
// "col" specifies the right edge, but popup doesn't fit, skip some
// columns when displaying the window.
wp->w_leftcol = -leftoff;
wp->w_width += leftoff;
if (wp->w_width < 0)
wp->w_width = 0;
}
} }
wp->w_height = wp->w_buffer->b_ml.ml_line_count - wp->w_topline wp->w_height = wp->w_buffer->b_ml.ml_line_count - wp->w_topline
@ -823,6 +839,7 @@ popup_adjust_position(win_T *wp)
// And redraw windows that were behind the popup. // And redraw windows that were behind the popup.
if (org_winrow != wp->w_winrow if (org_winrow != wp->w_winrow
|| org_wincol != wp->w_wincol || org_wincol != wp->w_wincol
|| org_leftcol != wp->w_leftcol
|| org_width != wp->w_width || org_width != wp->w_width
|| org_height != wp->w_height) || org_height != wp->w_height)
{ {
@ -1078,6 +1095,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
for (i = 0; i < 8; ++i) for (i = 0; i < 8; ++i)
wp->w_border_char[i] = 0; wp->w_border_char[i] = 0;
wp->w_want_scrollbar = 1; wp->w_want_scrollbar = 1;
wp->w_popup_fixed = 0;
// Deal with options. // Deal with options.
apply_options(wp, argvars[1].vval.v_dict); apply_options(wp, argvars[1].vval.v_dict);
@ -1909,7 +1927,7 @@ popup_check_cursor_pos()
static int static int
popup_masked(win_T *wp, int screencol, int screenline) popup_masked(win_T *wp, int screencol, int screenline)
{ {
int col = screencol - wp->w_wincol + 1; int col = screencol - wp->w_wincol + 1 + wp->w_leftcol;
int line = screenline - wp->w_winrow + 1; int line = screenline - wp->w_winrow + 1;
listitem_T *lio, *li; listitem_T *lio, *li;
int width, height; int width, height;
@ -1988,7 +2006,13 @@ update_popup_transparent(win_T *wp, int val)
linee = height + linee + 1; linee = height + linee + 1;
--cols; --cols;
cols -= wp->w_leftcol;
if (cols < 0)
cols = 0;
cole -= wp->w_leftcol;
--lines; --lines;
if (lines < 0)
lines = 0;
for (line = lines; line < linee && line < screen_Rows; ++line) for (line = lines; line < linee && line < screen_Rows; ++line)
for (col = cols; col < cole && col < screen_Columns; ++col) for (col = cols; col < cole && col < screen_Columns; ++col)
popup_transparent[(line + wp->w_winrow) * screen_Columns popup_transparent[(line + wp->w_winrow) * screen_Columns

View File

@ -777,6 +777,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 */
/**/
1602,
/**/ /**/
1601, 1601,
/**/ /**/