Skip to content

Commit bd483b3

Browse files
committed
patch 8.1.1902: cannot have an info popup without a border
Problem: Cannot have an info popup without a border. Solution: Add the "border" item to 'completepopup'.
1 parent e2c453d commit bd483b3

File tree

7 files changed

+67
-8
lines changed

7 files changed

+67
-8
lines changed

src/popupmnu.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ pum_set_selected(int n, int repeat)
745745
if (use_popup)
746746
{
747747
int col = pum_col + pum_width + 1;
748+
int row = pum_row + pum_selected - pum_first + 1;
748749

749750
if (Columns - col < 20 && Columns - col < pum_col)
750751
{
@@ -755,8 +756,8 @@ pum_set_selected(int n, int repeat)
755756
else
756757
curwin->w_maxwidth = Columns - col + 1;
757758
curwin->w_maxwidth -= popup_extra_width(curwin);
758-
popup_set_wantpos_rowcol(curwin,
759-
pum_row + pum_selected - pum_first, col);
759+
row -= popup_top_extra(curwin);
760+
popup_set_wantpos_rowcol(curwin, row, col);
760761
}
761762
# endif
762763
if (!resized

src/popupwin.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ add_popup_dicts(buf_T *buf, list_T *l)
935935
/*
936936
* Get the padding plus border at the top, adjusted to 1 if there is a title.
937937
*/
938-
static int
938+
int
939939
popup_top_extra(win_T *wp)
940940
{
941941
int extra = wp->w_popup_border[0] + wp->w_popup_padding[0];
@@ -1350,6 +1350,24 @@ parse_popup_option(win_T *wp, int is_preview)
13501350
*p = c;
13511351
}
13521352
}
1353+
else if (STRNCMP(s, "border:", 7) == 0)
1354+
{
1355+
char_u *arg = s + 7;
1356+
int on = STRNCMP(arg, "on", 2) == 0 && arg + 2 == p;
1357+
int off = STRNCMP(arg, "off", 3) == 0 && arg + 3 == p;
1358+
int i;
1359+
1360+
if (!on && !off)
1361+
return FAIL;
1362+
if (wp != NULL)
1363+
{
1364+
for (i = 0; i < 4; ++i)
1365+
wp->w_popup_border[i] = on ? 1 : 0;
1366+
if (off)
1367+
// only show the X for close when there is a border
1368+
wp->w_popup_close = POPCLOSE_NONE;
1369+
}
1370+
}
13531371
else
13541372
return FAIL;
13551373
}

src/proto/popupwin.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ void popup_drag(win_T *wp);
66
void popup_set_firstline(win_T *wp);
77
int popup_is_in_scrollbar(win_T *wp, int row, int col);
88
void popup_handle_scrollbar_click(win_T *wp, int row, int col);
9+
int popup_top_extra(win_T *wp);
910
int popup_height(win_T *wp);
1011
int popup_width(win_T *wp);
1112
int popup_extra_width(win_T *wp);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
|t+0&#ffffff0|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|a|w|o|r|d> @43
2+
|~+0#4040ff13&| @23| +0#0000001#e0e0e08|w|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| @1|w|o|r|d|s| |a|r|e| |c|o@1|l| | +0#4040ff13#ffffff0@11
3+
|~| @23| +0#0000001#ffd7ff255|a|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27
4+
|~| @23| +0#0000001#ffd7ff255|n|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27
5+
|~| @23| +0#0000001#ffd7ff255|t|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27
6+
|~| @73
7+
|~| @73
8+
|~| @73
9+
|~| @73
10+
|~| @73
11+
|~| @73
12+
|~| @73
13+
|~| @73
14+
|-+2#0000000&@1| |U|s|e|r| |d|e|f|i|n|e|d| |c|o|m|p|l|e|t|i|o|n| |(|^|U|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |4| +0#0000000&@26

src/testdir/gen_opt_test.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ let test_values = {
7878
\ 'complete': [['', 'w,b'], ['xxx']],
7979
\ 'concealcursor': [['', 'n', 'nvic'], ['xxx']],
8080
\ 'completeopt': [['', 'menu', 'menu,longest'], ['xxx', 'menu,,,longest,']],
81-
\ 'completepopup': [['', 'height:13', 'highlight:That', 'width:10,height:234,highlight:Mine'], ['height:yes', 'width:no', 'xxx', 'xxx:99']],
81+
\ 'completepopup': [['', 'height:13', 'highlight:That', 'width:10,height:234,highlight:Mine'], ['height:yes', 'width:no', 'xxx', 'xxx:99', 'border:maybe', 'border:1']],
8282
\ 'completeslash': [['', 'slash', 'backslash'], ['xxx']],
8383
\ 'cryptmethod': [['', 'zip'], ['xxx']],
8484
\ 'cscopequickfix': [['', 's-', 's-,c+,e0'], ['xxx', 's,g,d']],

src/testdir/test_popupwin.vim

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,14 +2193,11 @@ func Test_previewpopup()
21932193
call delete('Xheader.h')
21942194
endfunc
21952195

2196-
func Test_popupmenu_info()
2197-
CheckScreendump
2198-
2196+
func Get_popupmenu_lines()
21992197
let lines =<< trim END
22002198
set completeopt+=preview,popup
22012199
set completefunc=CompleteFuncDict
22022200
hi InfoPopup ctermbg=yellow
2203-
set completepopup=height:4,highlight:InfoPopup
22042201

22052202
func CompleteFuncDict(findstart, base)
22062203
if a:findstart
@@ -2249,7 +2246,16 @@ func Test_popupmenu_info()
22492246
endfunc
22502247
call setline(1, 'text text text text text text text ')
22512248
END
2249+
return lines
2250+
endfunc
2251+
2252+
func Test_popupmenu_info_border()
2253+
CheckScreendump
2254+
2255+
let lines = Get_popupmenu_lines()
2256+
call add(lines, 'set completepopup=height:4,highlight:InfoPopup')
22522257
call writefile(lines, 'XtestInfoPopup')
2258+
22532259
let buf = RunVimInTerminal('-S XtestInfoPopup', #{rows: 14})
22542260
call term_wait(buf, 50)
22552261

@@ -2269,4 +2275,21 @@ func Test_popupmenu_info()
22692275
call delete('XtestInfoPopup')
22702276
endfunc
22712277

2278+
func Test_popupmenu_info_noborder()
2279+
CheckScreendump
2280+
2281+
let lines = Get_popupmenu_lines()
2282+
call add(lines, 'set completepopup=height:4,border:off')
2283+
call writefile(lines, 'XtestInfoPopupNb')
2284+
2285+
let buf = RunVimInTerminal('-S XtestInfoPopupNb', #{rows: 14})
2286+
call term_wait(buf, 50)
2287+
2288+
call term_sendkeys(buf, "A\<C-X>\<C-U>")
2289+
call VerifyScreenDump(buf, 'Test_popupwin_infopopup_nb_1', {})
2290+
2291+
call StopVimInTerminal(buf)
2292+
call delete('XtestInfoPopupNb')
2293+
endfunc
2294+
22722295
" vim: shiftwidth=2 sts=2

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1902,
764766
/**/
765767
1901,
766768
/**/

0 commit comments

Comments
 (0)