Skip to content

Commit 6eb0bfd

Browse files
Arkissachrisbra
authored andcommitted
patch 9.2.0051: 'previewpopup' is missing features available in 'completepopup'
Problem: The 'previewpopup' option lacks several customization values that 'completepopup' supports, such as borders, shadows, and UI handles. Solution: Add support for "border", "borderhighlight", "close", "resize", and "shadow" to 'previewpopup' (Arkissa) closes: #18873 Signed-off-by: Arkissa <[email protected]> Signed-off-by: Girish Palya <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent c4a6fa3 commit 6eb0bfd

24 files changed

+395
-21
lines changed

runtime/doc/version9.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52585,6 +52585,8 @@ work in progress.
5258552585
Popups ~
5258652586
------
5258752587
- Support for transparency, see |popup-opacity|.
52588+
- 'previewpopup' supports the same values as 'completepopup' (except for
52589+
"align").
5258852590

5258952591
Other ~
5259052592
-----

runtime/doc/windows.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*windows.txt* For Vim version 9.2. Last change: 2026 Feb 14
1+
*windows.txt* For Vim version 9.2. Last change: 2026 Feb 24
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -954,11 +954,20 @@ windows.
954954
Alternatively, a popup window can be used by setting the 'previewpopup'
955955
option. When set, it overrules the 'previewwindow' and 'previewheight'
956956
settings. The option is a comma-separated list of values:
957+
border border style (see 'pumborder')
958+
borderhighlight highlight group for the popup border characters
959+
close show close button: "on" (default) or "off", and if
960+
the value is "on", it must be set after border.
957961
height maximum height of the popup
958-
width maximum width of the popup
959962
highlight highlight group of the popup (default is Pmenu)
963+
resize show resize handle: "on" (default) or "off"
964+
shadow "off" (default) or "on" using |hl-PmenuShadow|
965+
width maximum width of the popup
966+
960967
Example: >
961968
:set previewpopup=height:10,width:60
969+
:set previewpopup=border:single,borderhilight:PmenuBorder
970+
:set previewpopup=border:custom:─;│;─;│;┌;┐;┘;└
962971
963972
A few peculiarities:
964973
- If the file is in a buffer already, it will be re-used. This will allow for

src/optionstr.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,14 @@ static char *(p_kpc_protocol_values[]) = {"none", "mok2", "kitty", NULL};
7575
static char *(p_popup_cpp_option_values[]) = {"align:", "border:",
7676
"borderhighlight:", "close:", "height:", "highlight:", "resize:",
7777
"shadow:", "width:", NULL};
78-
static char *(p_popup_pvp_option_values[]) = {"height:", "highlight:",
79-
"width:", NULL};
78+
static char *(p_popup_pvp_option_values[]) = {"border:",
79+
"borderhighlight:", "close:", "height:", "highlight:", "resize:",
80+
"shadow:", "width:", NULL};
8081
static char *(p_popup_option_on_off_values[]) = {"on", "off", NULL};
8182
static char *(p_popup_cpp_border_values[]) = {"single", "double", "round",
8283
"ascii", "on", "off", "custom:", NULL};
84+
static char *(p_popup_pvp_border_values[]) = {"single", "double", "round",
85+
"ascii", "on", "off", "custom:", NULL};
8386
static char *(p_popup_option_align_values[]) = {"item", "menu", NULL};
8487
#endif
8588
#if defined(FEAT_SPELL)
@@ -3415,6 +3418,7 @@ did_set_previewpopup(optset_T *args UNUSED)
34153418
if (parse_previewpopup(NULL) == FAIL)
34163419
return e_invalid_argument;
34173420

3421+
popup_close_info();
34183422
return NULL;
34193423
}
34203424

@@ -3452,9 +3456,9 @@ expand_set_popupoption(optexpand_T *args, int *numMatches, char_u ***matches,
34523456
{
34533457
return expand_set_opt_string(
34543458
args,
3455-
previewpopup ? p_popup_option_on_off_values
3459+
previewpopup ? p_popup_pvp_border_values
34563460
: p_popup_cpp_border_values,
3457-
(previewpopup ? ARRAY_LENGTH(p_popup_option_on_off_values)
3461+
(previewpopup ? ARRAY_LENGTH(p_popup_pvp_border_values) - 1
34583462
: ARRAY_LENGTH(p_popup_cpp_border_values)) - 1,
34593463
numMatches,
34603464
matches);

src/popupwin.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,9 +2006,9 @@ parse_popup_option(win_T *wp, int is_preview)
20062006
int on = STRNCMP(arg, "on", 2) == 0 && arg + 2 == p;
20072007
int off = STRNCMP(arg, "off", 3) == 0 && arg + 3 == p;
20082008

2009-
if ((!on && !off) || is_preview)
2009+
if (!on && !off)
20102010
return FAIL;
2011-
on = on && mouse_has(MOUSE_INSERT) && border_enabled;
2011+
on = on && mouse_has(MOUSE_INSERT) && (border_enabled || is_preview);
20122012
if (wp != NULL)
20132013
wp->w_popup_close = on ? POPCLOSE_BUTTON : POPCLOSE_NONE;
20142014
}
@@ -2018,7 +2018,7 @@ parse_popup_option(win_T *wp, int is_preview)
20182018
int on = STRNCMP(arg, "on", 2) == 0 && arg + 2 == p;
20192019
int off = STRNCMP(arg, "off", 3) == 0 && arg + 3 == p;
20202020

2021-
if ((!on && !off) || is_preview)
2021+
if (!on && !off)
20222022
return FAIL;
20232023
if (wp != NULL)
20242024
{
@@ -2034,7 +2034,7 @@ parse_popup_option(win_T *wp, int is_preview)
20342034
int on = STRNCMP(arg, "on", 2) == 0 && arg + 2 == p;
20352035
int off = STRNCMP(arg, "off", 3) == 0 && arg + 3 == p;
20362036

2037-
if ((!on && !off) || is_preview)
2037+
if (!on && !off)
20382038
return FAIL;
20392039
if (wp != NULL)
20402040
wp->w_popup_shadow = on ? 1 : 0;
@@ -2457,21 +2457,24 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
24572457
wp->w_popup_flags |= POPF_CURSORLINE;
24582458
}
24592459

2460+
for (i = 0; i < 4; ++i)
2461+
VIM_CLEAR(wp->w_border_highlight[i]);
2462+
for (i = 0; i < 8; ++i)
2463+
wp->w_border_char[i] = 0;
2464+
24602465
if (type == TYPE_PREVIEW)
24612466
{
2462-
wp->w_popup_flags |= POPF_DRAG | POPF_RESIZE;
2463-
wp->w_popup_close = POPCLOSE_BUTTON;
2467+
if (mouse_has(MOUSE_INSERT))
2468+
{
2469+
wp->w_popup_flags |= POPF_DRAG | POPF_RESIZE;
2470+
wp->w_popup_close = POPCLOSE_BUTTON;
2471+
}
24642472
for (i = 0; i < 4; ++i)
24652473
wp->w_popup_border[i] = 1;
24662474
parse_previewpopup(wp);
24672475
popup_set_wantpos_cursor(wp, wp->w_minwidth, d);
24682476
}
24692477

2470-
for (i = 0; i < 4; ++i)
2471-
VIM_CLEAR(wp->w_border_highlight[i]);
2472-
for (i = 0; i < 8; ++i)
2473-
wp->w_border_char[i] = 0;
2474-
24752478
#ifdef FEAT_QUICKFIX
24762479
if (type == TYPE_INFO)
24772480
{
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
>o+0&#ffffff0|n|e| @71
2+
|┌+0#0000001#ffd7ff255| |X|p@1|f|i|l|e| |─@31|X| +0#0000000#ffffff0@31
3+
|│+0#0000001#ffd7ff255|1| @38| +0#0000000#0000001|│+0#0000001#ffd7ff255| +0#0000000#ffffff0@31
4+
|│+0#0000001#ffd7ff255|2| @38| +0#0000000#a8a8a8255|│+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@31
5+
|│+0#0000001#ffd7ff255|3| @38| +0#0000000#a8a8a8255|│+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@31
6+
|│+0#0000001#ffd7ff255|4| @38| +0#0000000#a8a8a8255|│+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@31
7+
|└+0#0000001#ffd7ff255|─@40|┘| +0#4040ff13#ffffff0@31
8+
|~| @73
9+
|~| @73
10+
|~| @73
11+
|~| @73
12+
|~| @73
13+
|~| @73
14+
|:+0#0000000&| @55|1|,|1| @10|A|l@1|
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
>o+0&#ffffff0|n|e| @71
2+
|╔+0#0000001#ffd7ff255| |X|p@1|f|i|l|e| |═@31|X| +0#0000000#ffffff0@31
3+
|║+0#0000001#ffd7ff255|1| @38| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@31
4+
|║+0#0000001#ffd7ff255|2| @38| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@31
5+
|║+0#0000001#ffd7ff255|3| @38| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@31
6+
|║+0#0000001#ffd7ff255|4| @38| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@31
7+
|╚+0#0000001#ffd7ff255|═@40|╝| +0#4040ff13#ffffff0@31
8+
|~| @73
9+
|~| @73
10+
|~| @73
11+
|~| @73
12+
|~| @73
13+
|~| @73
14+
|:+0#0000000&| @55|1|,|1| @10|A|l@1|
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
>o+0&#ffffff0|n|e| @71
2+
|╭+0#0000001#ffd7ff255| |X|p@1|f|i|l|e| |─@31|X| +0#0000000#ffffff0@31
3+
|│+0#0000001#ffd7ff255|1| @38| +0#0000000#0000001|│+0#0000001#ffd7ff255| +0#0000000#ffffff0@31
4+
|│+0#0000001#ffd7ff255|2| @38| +0#0000000#a8a8a8255|│+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@31
5+
|│+0#0000001#ffd7ff255|3| @38| +0#0000000#a8a8a8255|│+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@31
6+
|│+0#0000001#ffd7ff255|4| @38| +0#0000000#a8a8a8255|│+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@31
7+
|╰+0#0000001#ffd7ff255|─@40|╯| +0#4040ff13#ffffff0@31
8+
|~| @73
9+
|~| @73
10+
|~| @73
11+
|~| @73
12+
|~| @73
13+
|~| @73
14+
|:+0#0000000&| @55|1|,|1| @10|A|l@1|
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
>o+0&#ffffff0|n|e| @71
2+
|++0#0000001#ffd7ff255| |X|p@1|f|i|l|e| |-@31|X| +0#0000000#ffffff0@31
3+
||+0#0000001#ffd7ff255|1| @38| +0#0000000#0000001||+0#0000001#ffd7ff255| +0#0000000#ffffff0@31
4+
||+0#0000001#ffd7ff255|2| @38| +0#0000000#a8a8a8255||+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@31
5+
||+0#0000001#ffd7ff255|3| @38| +0#0000000#a8a8a8255||+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@31
6+
||+0#0000001#ffd7ff255|4| @38| +0#0000000#a8a8a8255||+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@31
7+
|++0#0000001#ffd7ff255|-@40|+| +0#4040ff13#ffffff0@31
8+
|~| @73
9+
|~| @73
10+
|~| @73
11+
|~| @73
12+
|~| @73
13+
|~| @73
14+
|:+0#0000000&| @55|1|,|1| @10|A|l@1|
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
>o+0&#ffffff0|n|e| @71
2+
|┌+0&#afffff255| |X|p@1|f|i|l|e| |─@31|X| +0&#ffffff0@31
3+
|│+0&#afffff255|1+0#0000001#ffd7ff255| @38| +0#0000000#0000001|│+0&#afffff255| +0&#ffffff0@31
4+
|│+0&#afffff255|2+0#0000001#ffd7ff255| @38| +0#0000000#a8a8a8255|│+0&#afffff255| +0#4040ff13#ffffff0@31
5+
|│+0#0000000#afffff255|3+0#0000001#ffd7ff255| @38| +0#0000000#a8a8a8255|│+0&#afffff255| +0#4040ff13#ffffff0@31
6+
|│+0#0000000#afffff255|4+0#0000001#ffd7ff255| @38| +0#0000000#a8a8a8255|│+0&#afffff255| +0#4040ff13#ffffff0@31
7+
|└+0#0000000#afffff255|─@40|┘| +0#4040ff13#ffffff0@31
8+
|~| @73
9+
|~| @73
10+
|~| @73
11+
|~| @73
12+
|~| @73
13+
|~| @73
14+
|:+0#0000000&| @55|1|,|1| @10|A|l@1|
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
>o+0&#ffffff0|n|e| @71
2+
|╔+0&#afffff255| |X|p@1|f|i|l|e| |═@31|X| +0&#ffffff0@31
3+
|║+0&#afffff255|1+0#0000001#ffd7ff255| @38| +0#0000000#0000001|║+0&#afffff255| +0&#ffffff0@31
4+
|║+0&#afffff255|2+0#0000001#ffd7ff255| @38| +0#0000000#a8a8a8255|║+0&#afffff255| +0#4040ff13#ffffff0@31
5+
|║+0#0000000#afffff255|3+0#0000001#ffd7ff255| @38| +0#0000000#a8a8a8255|║+0&#afffff255| +0#4040ff13#ffffff0@31
6+
|║+0#0000000#afffff255|4+0#0000001#ffd7ff255| @38| +0#0000000#a8a8a8255|║+0&#afffff255| +0#4040ff13#ffffff0@31
7+
|╚+0#0000000#afffff255|═@40|⇲| +0#4040ff13#ffffff0@31
8+
|~| @73
9+
|~| @73
10+
|~| @73
11+
|~| @73
12+
|~| @73
13+
|~| @73
14+
|:+0#0000000&| @55|1|,|1| @10|A|l@1|

0 commit comments

Comments
 (0)