0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

patch 8.1.1773: the preview popup window may be too far to the right

Problem:    The preview popup window may be too far to the right.
Solution:   Keep it inside the screen.  Also keep the close button and
            scrollbar visible if possible.
This commit is contained in:
Bram Moolenaar
2019-07-28 21:42:38 +02:00
parent b78564d022
commit 13d5c3f616
11 changed files with 186 additions and 119 deletions

View File

@@ -5138,7 +5138,7 @@ prepare_tagpreview(
{ {
wp = popup_find_preview_window(); wp = popup_find_preview_window();
if (wp != NULL) if (wp != NULL)
popup_set_wantpos(wp); popup_set_wantpos(wp, wp->w_minwidth);
} }
else else
# endif # endif

View File

@@ -1026,6 +1026,8 @@ popup_adjust_position(win_T *wp)
wp->w_has_scrollbar = wp->w_want_scrollbar wp->w_has_scrollbar = wp->w_want_scrollbar
&& (wp->w_topline > 1 || lnum <= wp->w_buffer->b_ml.ml_line_count); && (wp->w_topline > 1 || lnum <= wp->w_buffer->b_ml.ml_line_count);
if (wp->w_has_scrollbar)
++right_extra;
minwidth = wp->w_minwidth; minwidth = wp->w_minwidth;
if (wp->w_popup_title != NULL && *wp->w_popup_title != NUL) if (wp->w_popup_title != NULL && *wp->w_popup_title != NUL)
@@ -1040,7 +1042,7 @@ popup_adjust_position(win_T *wp)
wp->w_width = minwidth; wp->w_width = minwidth;
if (wp->w_width > maxwidth) if (wp->w_width > maxwidth)
{ {
if (wp->w_width > maxspace) if (wp->w_width > maxspace && !wp->w_p_wrap)
// some columns cut off on the right // some columns cut off on the right
wp->w_popup_rightoff = wp->w_width - maxspace; wp->w_popup_rightoff = wp->w_width - maxspace;
wp->w_width = maxwidth; wp->w_width = maxwidth;
@@ -1074,6 +1076,26 @@ popup_adjust_position(win_T *wp)
} }
} }
if (wp->w_p_wrap)
{
int want_col = 0;
if (wp->w_popup_close == POPCLOSE_BUTTON)
// try to show the close button
want_col = left_extra + wp->w_width + right_extra;
else if (wp->w_has_scrollbar)
// try to show the scrollbar
want_col = left_extra + wp->w_width
+ right_extra - wp->w_popup_border[1];
if (want_col > 0 && wp->w_wincol > 0
&& wp->w_wincol + want_col >= Columns)
{
wp->w_wincol = Columns - want_col;
if (wp->w_wincol < 0)
wp->w_wincol = 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
+ 1 + wrapped; + 1 + wrapped;
if (wp->w_minheight > 0 && wp->w_height < wp->w_minheight) if (wp->w_minheight > 0 && wp->w_height < wp->w_minheight)
@@ -1112,6 +1134,9 @@ popup_adjust_position(win_T *wp)
|| org_height != wp->w_height) || org_height != wp->w_height)
{ {
redraw_all_later(VALID); redraw_all_later(VALID);
redraw_win_later(wp, NOT_VALID);
if (wp->w_popup_flags & POPF_ON_CMDLINE)
clear_cmdline = TRUE;
popup_mask_refresh = TRUE; popup_mask_refresh = TRUE;
} }
} }
@@ -1221,9 +1246,10 @@ parse_previewpopup(win_T *wp)
/* /*
* Set w_wantline and w_wantcol for the cursor position in the current window. * Set w_wantline and w_wantcol for the cursor position in the current window.
* Keep at least "width" columns from the right of the screen.
*/ */
void void
popup_set_wantpos(win_T *wp) popup_set_wantpos(win_T *wp, int width)
{ {
setcursor_mayforce(TRUE); setcursor_mayforce(TRUE);
wp->w_wantline = curwin->w_winrow + curwin->w_wrow; wp->w_wantline = curwin->w_winrow + curwin->w_wrow;
@@ -1232,7 +1258,14 @@ popup_set_wantpos(win_T *wp)
wp->w_wantline = 2; wp->w_wantline = 2;
wp->w_popup_pos = POPPOS_TOPLEFT; wp->w_popup_pos = POPPOS_TOPLEFT;
} }
wp->w_wantcol = curwin->w_wincol + curwin->w_wcol + 1; wp->w_wantcol = curwin->w_wincol + curwin->w_wcol + 1;
if (wp->w_wantcol > Columns - width)
{
wp->w_wantcol = Columns - width;
if (wp->w_wantcol < 1)
wp->w_wantcol = 1;
}
popup_adjust_position(wp); popup_adjust_position(wp);
} }
@@ -1378,10 +1411,10 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
if (type == TYPE_ATCURSOR || type == TYPE_PREVIEW) if (type == TYPE_ATCURSOR || type == TYPE_PREVIEW)
{ {
wp->w_popup_pos = POPPOS_BOTLEFT; wp->w_popup_pos = POPPOS_BOTLEFT;
popup_set_wantpos(wp);
} }
if (type == TYPE_ATCURSOR) if (type == TYPE_ATCURSOR)
{ {
popup_set_wantpos(wp, 0);
set_moved_values(wp); set_moved_values(wp);
set_moved_columns(wp, FIND_STRING); set_moved_columns(wp, FIND_STRING);
} }
@@ -1485,6 +1518,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
wp->w_popup_border[i] = 1; wp->w_popup_border[i] = 1;
parse_previewpopup(wp); parse_previewpopup(wp);
popup_set_wantpos(wp, wp->w_minwidth);
} }
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
@@ -1878,6 +1912,7 @@ f_popup_settext(typval_T *argvars, typval_T *rettv UNUSED)
else else
{ {
popup_set_buffer_text(wp->w_buffer, argvars[1]); popup_set_buffer_text(wp->w_buffer, argvars[1]);
redraw_win_later(wp, NOT_VALID);
popup_adjust_position(wp); popup_adjust_position(wp);
} }
} }
@@ -1888,7 +1923,7 @@ popup_free(win_T *wp)
{ {
sign_undefine_by_name(popup_get_sign_name(wp), FALSE); sign_undefine_by_name(popup_get_sign_name(wp), FALSE);
wp->w_buffer->b_locked = FALSE; wp->w_buffer->b_locked = FALSE;
if (wp->w_winrow + wp->w_height >= cmdline_row) if (wp->w_winrow + popup_height(wp) >= cmdline_row)
clear_cmdline = TRUE; clear_cmdline = TRUE;
win_free_popup(wp); win_free_popup(wp);
@@ -2756,6 +2791,12 @@ update_popups(void (*win_update)(win_T *wp))
total_height = popup_height(wp); total_height = popup_height(wp);
popup_attr = get_wcr_attr(wp); popup_attr = get_wcr_attr(wp);
if (wp->w_winrow + total_height > cmdline_row)
wp->w_popup_flags |= POPF_ON_CMDLINE;
else
wp->w_popup_flags &= ~POPF_ON_CMDLINE;
// We can only use these line drawing characters when 'encoding' is // We can only use these line drawing characters when 'encoding' is
// "utf-8" and 'ambiwidth' is "single". // "utf-8" and 'ambiwidth' is "single".
if (enc_utf8 && *p_ambw == 's') if (enc_utf8 && *p_ambw == 's')

View File

@@ -9,7 +9,7 @@ int popup_height(win_T *wp);
int popup_width(win_T *wp); int popup_width(win_T *wp);
void popup_adjust_position(win_T *wp); void popup_adjust_position(win_T *wp);
int parse_previewpopup(win_T *wp); int parse_previewpopup(win_T *wp);
void popup_set_wantpos(win_T *wp); void popup_set_wantpos(win_T *wp, int width);
void f_popup_clear(typval_T *argvars, typval_T *rettv); void f_popup_clear(typval_T *argvars, typval_T *rettv);
void f_popup_create(typval_T *argvars, typval_T *rettv); void f_popup_create(typval_T *argvars, typval_T *rettv);
void f_popup_atcursor(typval_T *argvars, typval_T *rettv); void f_popup_atcursor(typval_T *argvars, typval_T *rettv);

View File

@@ -795,6 +795,11 @@ update_screen(int type_arg)
FOR_ALL_WINDOWS(wp) FOR_ALL_WINDOWS(wp)
wp->w_buffer->b_mod_set = FALSE; wp->w_buffer->b_mod_set = FALSE;
#ifdef FEAT_TEXT_PROP
// Display popup windows on top of the windows and command line.
update_popups(win_update);
#endif
after_updating_screen(TRUE); after_updating_screen(TRUE);
/* Clear or redraw the command line. Done last, because scrolling may /* Clear or redraw the command line. Done last, because scrolling may
@@ -810,11 +815,6 @@ update_screen(int type_arg)
maybe_intro_message(); maybe_intro_message();
did_intro = TRUE; did_intro = TRUE;
#ifdef FEAT_TEXT_PROP
// Display popup windows on top of the windows.
update_popups(win_update);
#endif
#ifdef FEAT_GUI #ifdef FEAT_GUI
/* Redraw the cursor and update the scrollbars when all screen updating is /* Redraw the cursor and update the scrollbars when all screen updating is
* done. */ * done. */

View File

@@ -8,7 +8,7 @@
|f|i|n|d| >t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e| @52 |f|i|n|d| >t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e| @52
|n|i|n|e| @70 |n|i|n|e| @70
|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d| @54 |t|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d| @54
|v|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d| |i|s| |a|l|s|o| |a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73 |~+0#4040ff13&| @73
|~| @73 |~| @73
|~| @73
|:+0#0000000&| @55|8|,|6| @10|A|l@1| |:+0#0000000&| @55|8|,|6| @10|A|l@1|

View File

@@ -8,7 +8,7 @@
|f|i|n|d| |t|h|e|║+0#0000001#ffd7ff255|3|0| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@23 |f|i|n|d| |t|h|e|║+0#0000001#ffd7ff255|3|0| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@23
|n|i|n|e| @3|╚+0#0000001#ffd7ff255|═@40|╝| +0#0000000#ffffff0@23 |n|i|n|e| @3|╚+0#0000001#ffd7ff255|═@40|╝| +0#0000000#ffffff0@23
|t|h|i|s| |i|s| >a|n|o|t|h|e|r| |w|o|r|d| @54 |t|h|i|s| |i|s| >a|n|o|t|h|e|r| |w|o|r|d| @54
|v|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d| |i|s| |a|l|s|o| |a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73 |~+0#4040ff13&| @73
|~| @73 |~| @73
|~| @73
|/+0#0000000&|a|n|o|t|h|e|r| @48|1|0|,|9| @9|A|l@1| |/+0#0000000&|a|n|o|t|h|e|r| @48|1|0|,|9| @9|A|l@1|

View File

@@ -8,7 +8,7 @@
|f|i|n|d| |t|h|e|w|o|r|d| |s|║+0#0000001#ffd7ff255|3|0| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17 |f|i|n|d| |t|h|e|w|o|r|d| |s|║+0#0000001#ffd7ff255|3|0| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
|n|i|n|e| @9|╚+0#0000001#ffd7ff255|═@40|╝| +0#0000000#ffffff0@17 |n|i|n|e| @9|╚+0#0000001#ffd7ff255|═@40|╝| +0#0000000#ffffff0@17
|t|h|i|s| |i|s| >a|n|o|t|h|e|r| |w|o|r|d| @54 |t|h|i|s| |i|s| >a|n|o|t|h|e|r| |w|o|r|d| @54
|v|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d| |i|s| |a|l|s|o| |a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73 |~+0#4040ff13&| @73
|~| @73 |~| @73
|~| @73
|:+0#0000000&| @55|1|0|,|9| @9|A|l@1| |:+0#0000000&| @55|1|0|,|9| @9|A|l@1|

View File

@@ -0,0 +1,14 @@
|o+0&#ffffff0|n|e| @71
|t|w|o| @71
|t|h|r|e@1| @69
|f|o|u|r| @70
|f|i|v|e| @27|╔+0#0000001#ffd7ff255|═@40|X
|s+0#0000000#ffffff0|i|x| @28|║+0#0000001#ffd7ff255|2|7| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
|s+0#0000000#ffffff0|e|v|e|n| @26|║+0#0000001#ffd7ff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
|f+0#0000000#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e| @9|║+0#0000001#ffd7ff255|2|9| @37| +0#0000000#0000001|║+0#0000001#ffd7ff255
|n+0#0000000#ffffff0|i|n|e| @27|║+0#0000001#ffd7ff255|3|0| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
|t+0#0000000#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d| @11|╚+0#0000001#ffd7ff255|═@40|╝
|v+0#0000000#ffffff0|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d| |i|s| |a|l|s|o| >a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73
|~| @73
|/+0#0000000&|a|n|o|t|h|e|r| @48|1@1|,|3|9| @8|A|l@1|

View File

@@ -1009,9 +1009,9 @@ func Test_popup_atcursor()
call cursor(1, 1) call cursor(1, 1)
redraw redraw
let winid = popup_create('vim', #{ let winid = popup_create('vim', #{
\ line: 'cursor+2', \ line: 'cursor+2',
\ col: 'cursor+1', \ col: 'cursor+1',
\}) \})
redraw redraw
let line = join(map(range(1, 17), 'screenstring(3, v:val)'), '') let line = join(map(range(1, 17), 'screenstring(3, v:val)'), '')
call assert_equal('xvimxxxxxxxxxxxxx', line) call assert_equal('xvimxxxxxxxxxxxxx', line)
@@ -1020,9 +1020,9 @@ func Test_popup_atcursor()
call cursor(3, 3) call cursor(3, 3)
redraw redraw
let winid = popup_create('vim', #{ let winid = popup_create('vim', #{
\ line: 'cursor-2', \ line: 'cursor-2',
\ col: 'cursor-1', \ col: 'cursor-1',
\}) \})
redraw redraw
let line = join(map(range(1, 17), 'screenstring(1, v:val)'), '') let line = join(map(range(1, 17), 'screenstring(1, v:val)'), '')
call assert_equal('xvimxxxxxxxxxxxxx', line) call assert_equal('xvimxxxxxxxxxxxxx', line)
@@ -1347,11 +1347,11 @@ func Test_popup_never_behind()
call delete('XtestPopupBehind') call delete('XtestPopupBehind')
endfunc endfunc
func s:VerifyPosition( p, msg, line, col, width, height ) func s:VerifyPosition(p, msg, line, col, width, height)
call assert_equal( a:line, popup_getpos( a:p ).line, a:msg . ' (l)' ) call assert_equal(a:line, popup_getpos(a:p).line, a:msg . ' (l)')
call assert_equal( a:col, popup_getpos( a:p ).col, a:msg . ' (c)' ) call assert_equal(a:col, popup_getpos(a:p).col, a:msg . ' (c)')
call assert_equal( a:width, popup_getpos( a:p ).width, a:msg . ' (w)' ) call assert_equal(a:width, popup_getpos(a:p).width, a:msg . ' (w)')
call assert_equal( a:height, popup_getpos( a:p ).height, a:msg . ' (h)' ) call assert_equal(a:height, popup_getpos(a:p).height, a:msg . ' (h)')
endfunc endfunc
func Test_popup_position_adjust() func Test_popup_position_adjust()
@@ -1364,24 +1364,24 @@ func Test_popup_position_adjust()
" Entries for cases which don't vary based on wrapping. " Entries for cases which don't vary based on wrapping.
" Format is per tests described below " Format is per tests described below
let both_wrap_tests = [ let both_wrap_tests = [
\ [ 'a', 5, &columns, 5, &columns - 2, 1, 1 ], \ ['a', 5, &columns, 5, &columns - 2, 1, 1],
\ [ 'b', 5, &columns + 1, 5, &columns - 2, 1, 1 ], \ ['b', 5, &columns + 1, 5, &columns - 2, 1, 1],
\ [ 'c', 5, &columns - 1, 5, &columns - 2, 1, 1 ], \ ['c', 5, &columns - 1, 5, &columns - 2, 1, 1],
\ [ 'd', 5, &columns - 2, 5, &columns - 2, 1, 1 ], \ ['d', 5, &columns - 2, 5, &columns - 2, 1, 1],
\ [ 'e', 5, &columns - 3, 5, &columns - 3, 1, 1 ], \ ['e', 5, &columns - 3, 5, &columns - 3, 1, 1],
\ \
\ [ 'aa', 5, &columns, 5, &columns - 2, 2, 1 ], \ ['aa', 5, &columns, 5, &columns - 2, 2, 1],
\ [ 'bb', 5, &columns + 1, 5, &columns - 2, 2, 1 ], \ ['bb', 5, &columns + 1, 5, &columns - 2, 2, 1],
\ [ 'cc', 5, &columns - 1, 5, &columns - 2, 2, 1 ], \ ['cc', 5, &columns - 1, 5, &columns - 2, 2, 1],
\ [ 'dd', 5, &columns - 2, 5, &columns - 2, 2, 1 ], \ ['dd', 5, &columns - 2, 5, &columns - 2, 2, 1],
\ [ 'ee', 5, &columns - 3, 5, &columns - 3, 2, 1 ], \ ['ee', 5, &columns - 3, 5, &columns - 3, 2, 1],
\ \
\ [ 'aaa', 5, &columns, 5, &columns - 2, 3, 1 ], \ ['aaa', 5, &columns, 5, &columns - 2, 3, 1],
\ [ 'bbb', 5, &columns + 1, 5, &columns - 2, 3, 1 ], \ ['bbb', 5, &columns + 1, 5, &columns - 2, 3, 1],
\ [ 'ccc', 5, &columns - 1, 5, &columns - 2, 3, 1 ], \ ['ccc', 5, &columns - 1, 5, &columns - 2, 3, 1],
\ [ 'ddd', 5, &columns - 2, 5, &columns - 2, 3, 1 ], \ ['ddd', 5, &columns - 2, 5, &columns - 2, 3, 1],
\ [ 'eee', 5, &columns - 3, 5, &columns - 3, 3, 1 ], \ ['eee', 5, &columns - 3, 5, &columns - 3, 3, 1],
\ ] \ ]
" these test groups are dicts with: " these test groups are dicts with:
" - comment: something to identify the group of tests by " - comment: something to identify the group of tests by
@@ -1395,61 +1395,61 @@ func Test_popup_position_adjust()
" - expected width " - expected width
" - expected height " - expected height
let tests = [ let tests = [
\ #{ \ #{
\ comment: 'left-aligned with wrapping', \ comment: 'left-aligned with wrapping',
\ options: #{ \ options: #{
\ wrap: 1, \ wrap: 1,
\ pos: 'botleft', \ pos: 'botleft',
\ }, \ },
\ tests: both_wrap_tests + [ \ tests: both_wrap_tests + [
\ [ 'aaaa', 5, &columns, 4, &columns - 2, 3, 2 ], \ ['aaaa', 5, &columns, 4, &columns - 2, 3, 2],
\ [ 'bbbb', 5, &columns + 1, 4, &columns - 2, 3, 2 ], \ ['bbbb', 5, &columns + 1, 4, &columns - 2, 3, 2],
\ [ 'cccc', 5, &columns - 1, 4, &columns - 2, 3, 2 ], \ ['cccc', 5, &columns - 1, 4, &columns - 2, 3, 2],
\ [ 'dddd', 5, &columns - 2, 4, &columns - 2, 3, 2 ], \ ['dddd', 5, &columns - 2, 4, &columns - 2, 3, 2],
\ [ 'eeee', 5, &columns - 3, 5, &columns - 3, 4, 1 ], \ ['eeee', 5, &columns - 3, 5, &columns - 3, 4, 1],
\ ], \ ],
\ }, \ },
\ #{ \ #{
\ comment: 'left aligned without wrapping', \ comment: 'left aligned without wrapping',
\ options: #{ \ options: #{
\ wrap: 0, \ wrap: 0,
\ pos: 'botleft', \ pos: 'botleft',
\ }, \ },
\ tests: both_wrap_tests + [ \ tests: both_wrap_tests + [
\ [ 'aaaa', 5, &columns, 5, &columns - 3, 4, 1 ], \ ['aaaa', 5, &columns, 5, &columns - 3, 4, 1],
\ [ 'bbbb', 5, &columns + 1, 5, &columns - 3, 4, 1 ], \ ['bbbb', 5, &columns + 1, 5, &columns - 3, 4, 1],
\ [ 'cccc', 5, &columns - 1, 5, &columns - 3, 4, 1 ], \ ['cccc', 5, &columns - 1, 5, &columns - 3, 4, 1],
\ [ 'dddd', 5, &columns - 2, 5, &columns - 3, 4, 1 ], \ ['dddd', 5, &columns - 2, 5, &columns - 3, 4, 1],
\ [ 'eeee', 5, &columns - 3, 5, &columns - 3, 4, 1 ], \ ['eeee', 5, &columns - 3, 5, &columns - 3, 4, 1],
\ ], \ ],
\ }, \ },
\ #{ \ #{
\ comment: 'left aligned with fixed position', \ comment: 'left aligned with fixed position',
\ options: #{ \ options: #{
\ wrap: 0, \ wrap: 0,
\ fixed: 1, \ fixed: 1,
\ pos: 'botleft', \ pos: 'botleft',
\ }, \ },
\ tests: both_wrap_tests + [ \ tests: both_wrap_tests + [
\ [ 'aaaa', 5, &columns, 5, &columns - 2, 3, 1 ], \ ['aaaa', 5, &columns, 5, &columns - 2, 3, 1],
\ [ 'bbbb', 5, &columns + 1, 5, &columns - 2, 3, 1 ], \ ['bbbb', 5, &columns + 1, 5, &columns - 2, 3, 1],
\ [ 'cccc', 5, &columns - 1, 5, &columns - 2, 3, 1 ], \ ['cccc', 5, &columns - 1, 5, &columns - 2, 3, 1],
\ [ 'dddd', 5, &columns - 2, 5, &columns - 2, 3, 1 ], \ ['dddd', 5, &columns - 2, 5, &columns - 2, 3, 1],
\ [ 'eeee', 5, &columns - 3, 5, &columns - 3, 4, 1 ], \ ['eeee', 5, &columns - 3, 5, &columns - 3, 4, 1],
\ ], \ ],
\ }, \ },
\ ] \ ]
for test_group in tests for test_group in tests
for test in test_group.tests for test in test_group.tests
let [ text, line, col, e_line, e_col, e_width, e_height ] = test let [ text, line, col, e_line, e_col, e_width, e_height ] = test
let options = #{ let options = #{
\ line: line, \ line: line,
\ col: col, \ col: col,
\ } \ }
call extend( options, test_group.options ) call extend(options, test_group.options)
let p = popup_create( text, options ) let p = popup_create(text, options)
let msg = string(extend(options, #{text: text})) let msg = string(extend(options, #{text: text}))
call s:VerifyPosition(p, msg, e_line, e_col, e_width, e_height) call s:VerifyPosition(p, msg, e_line, e_col, e_width, e_height)
@@ -1465,62 +1465,62 @@ func Test_adjust_left_past_screen_width()
" width of screen " width of screen
let X = join(map(range(&columns), {->'X'}), '') let X = join(map(range(&columns), {->'X'}), '')
let p = popup_create( X, #{line: 1, col: 1, wrap: 0}) let p = popup_create(X, #{line: 1, col: 1, wrap: 0})
call s:VerifyPosition( p, 'full width topleft', 1, 1, &columns, 1 ) call s:VerifyPosition(p, 'full width topleft', 1, 1, &columns, 1)
redraw redraw
let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '')
call assert_equal(X, line) call assert_equal(X, line)
call popup_close( p ) call popup_close(p)
redraw redraw
" Same if placed on the right hand side " Same if placed on the right hand side
let p = popup_create( X, #{line: 1, col: &columns, wrap: 0}) let p = popup_create(X, #{line: 1, col: &columns, wrap: 0})
call s:VerifyPosition( p, 'full width topright', 1, 1, &columns, 1 ) call s:VerifyPosition(p, 'full width topright', 1, 1, &columns, 1)
redraw redraw
let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '')
call assert_equal(X, line) call assert_equal(X, line)
call popup_close( p ) call popup_close(p)
redraw redraw
" Extend so > window width " Extend so > window width
let X .= 'x' let X .= 'x'
let p = popup_create( X, #{line: 1, col: 1, wrap: 0}) let p = popup_create(X, #{line: 1, col: 1, wrap: 0})
call s:VerifyPosition( p, 'full width + 1 topleft', 1, 1, &columns, 1 ) call s:VerifyPosition(p, 'full width + 1 topleft', 1, 1, &columns, 1)
redraw redraw
let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '')
call assert_equal(X[ : -2 ], line) call assert_equal(X[ : -2 ], line)
call popup_close( p ) call popup_close(p)
redraw redraw
" Shifted then truncated (the x is not visible) " Shifted then truncated (the x is not visible)
let p = popup_create( X, #{line: 1, col: &columns - 3, wrap: 0}) let p = popup_create(X, #{line: 1, col: &columns - 3, wrap: 0})
call s:VerifyPosition( p, 'full width + 1 topright', 1, 1, &columns, 1 ) call s:VerifyPosition(p, 'full width + 1 topright', 1, 1, &columns, 1)
redraw redraw
let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '')
call assert_equal(X[ : -2 ], line) call assert_equal(X[ : -2 ], line)
call popup_close( p ) call popup_close(p)
redraw redraw
" Not shifted, just truncated " Not shifted, just truncated
let p = popup_create( X, let p = popup_create(X,
\ #{line: 1, col: 2, wrap: 0, fixed: 1}) \ #{line: 1, col: 2, wrap: 0, fixed: 1})
call s:VerifyPosition( p, 'full width + 1 fixed', 1, 2, &columns - 1, 1) call s:VerifyPosition(p, 'full width + 1 fixed', 1, 2, &columns - 1, 1)
redraw redraw
let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '')
let e_line = ' ' . X[ 1 : -2 ] let e_line = ' ' . X[ 1 : -2 ]
call assert_equal(e_line, line) call assert_equal(e_line, line)
call popup_close( p ) call popup_close(p)
redraw redraw
call popup_clear() call popup_clear()
@@ -1715,7 +1715,7 @@ func Test_popup_settext()
call popup_settext(p, 'this is a text') call popup_settext(p, 'this is a text')
END END
call writefile( lines, 'XtestPopupSetText' ) call writefile(lines, 'XtestPopupSetText')
let buf = RunVimInTerminal('-S XtestPopupSetText', #{rows: 10}) let buf = RunVimInTerminal('-S XtestPopupSetText', #{rows: 10})
call VerifyScreenDump(buf, 'Test_popup_settext_01', {}) call VerifyScreenDump(buf, 'Test_popup_settext_01', {})
@@ -2155,16 +2155,17 @@ func Test_previewpopup()
let lines =<< trim END let lines =<< trim END
set tags=Xtags set tags=Xtags
call setline(1, [ call setline(1, [
\ 'one', \ 'one',
\ 'two', \ 'two',
\ 'three', \ 'three',
\ 'four', \ 'four',
\ 'five', \ 'five',
\ 'six', \ 'six',
\ 'seven', \ 'seven',
\ 'find theword somewhere', \ 'find theword somewhere',
\ 'nine', \ 'nine',
\ 'this is another word']) \ 'this is another word',
\ 'very long line where the word is also another'])
set previewpopup=height:4,width:40 set previewpopup=height:4,width:40
END END
call writefile(lines, 'XtestPreviewPopup') call writefile(lines, 'XtestPreviewPopup')
@@ -2177,6 +2178,13 @@ func Test_previewpopup()
call term_sendkeys(buf, "/another\<CR>\<C-W>}") call term_sendkeys(buf, "/another\<CR>\<C-W>}")
call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_2', {}) call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_2', {})
call term_sendkeys(buf, ":call popup_move(popup_getpreview(), #{col: 15})\<CR>")
call term_sendkeys(buf, ":\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_3', {})
call term_sendkeys(buf, "/another\<CR>\<C-W>}")
call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_4', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xtags') call delete('Xtags')
call delete('Xtagfile') call delete('Xtagfile')

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 */
/**/
1773,
/**/ /**/
1772, 1772,
/**/ /**/

View File

@@ -618,6 +618,8 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
#define POPF_HIDDEN 2 // popup is not displayed #define POPF_HIDDEN 2 // popup is not displayed
#define POPF_HANDLED 4 // popup was just redrawn or filtered #define POPF_HANDLED 4 // popup was just redrawn or filtered
#define POPF_CURSORLINE 8 // popup is highlighting at the cursorline #define POPF_CURSORLINE 8 // popup is highlighting at the cursorline
#define POPF_ON_CMDLINE 16 // popup overlaps command line
#ifdef FEAT_TEXT_PROP #ifdef FEAT_TEXT_PROP
# define WIN_IS_POPUP(wp) ((wp)->w_popup_flags != 0) # define WIN_IS_POPUP(wp) ((wp)->w_popup_flags != 0)
#else #else