Skip to content

Commit e700dde

Browse files
ychinchrisbra
authored andcommitted
patch 9.1.1123: popup hi groups not falling back to defaults
Problem: Highlight groups PopupSelected/PopupNotification/ MessageWindow are supposed to fall back to default highlight groups if they are not defined. However, once a colorscheme has defined them, switching to another colorscheme that doesn't do so will leave behind a cleared colorscheme, which causes the fallback to fail. Solution: Set up default links to the relevant fallback highlight groups, which makes sure a `:hi clear` command will reset the state properly (Yee Cheng Chin). closes: #16676 Signed-off-by: Yee Cheng Chin <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 911742a commit e700dde

7 files changed

Lines changed: 21 additions & 17 deletions

File tree

runtime/doc/popup.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*popup.txt* For Vim version 9.1. Last change: 2025 Jan 08
1+
*popup.txt* For Vim version 9.1. Last change: 2025 Feb 20
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -504,7 +504,7 @@ popup_menu({what}, {options}) *popup_menu()*
504504
\ mapping: 0,
505505
\ })
506506
< The current line is highlighted with a match using
507-
"PopupSelected", or "PmenuSel" if that is not defined.
507+
|hl-PopupSelected| which is linked to "PmenuSel" by default.
508508

509509
Use {options} to change the properties. Should at least set
510510
"callback" to a function that handles the selected item.
@@ -559,7 +559,7 @@ popup_notification({what}, {options}) *popup_notification()*
559559
\ close: 'click',
560560
\ padding: [0,1,0,1],
561561
\ })
562-
< The PopupNotification highlight group is used instead of
562+
< The |hl-PopupNotification| highlight group is used instead of
563563
WarningMsg if it is defined.
564564

565565
Without the |+timers| feature the popup will not disappear

runtime/doc/syntax.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*syntax.txt* For Vim version 9.1. Last change: 2025 Jan 20
1+
*syntax.txt* For Vim version 9.1. Last change: 2025 Feb 20
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -5831,8 +5831,8 @@ CursorLineSign Like SignColumn when 'cursorline' is set for the cursor line.
58315831
MatchParen Character under the cursor or just before it, if it
58325832
is a paired bracket, and its match. |pi_paren.txt|
58335833
*hl-MessageWindow*
5834-
MessageWindow Messages popup window used by `:echowindow`. If not defined
5835-
|hl-WarningMsg| is used.
5834+
MessageWindow Messages popup window used by `:echowindow`. Linked to
5835+
|hl-WarningMsg| by default.
58365836
*hl-ModeMsg*
58375837
ModeMsg 'showmode' message (e.g., "-- INSERT --").
58385838
*hl-MsgArea*
@@ -5872,10 +5872,13 @@ PmenuMatchSel Popup menu: Matched text in selected item. Applied in
58725872
combination with |hl-PmenuSel|.
58735873
*hl-ComplMatchIns*
58745874
ComplMatchIns Matched text of the currently inserted completion.
5875+
*hl-PopupSelected*
5876+
PopupSelected Popup window created with |popup_menu()|. Linked to
5877+
|hl-PmenuSel| by default.
58755878
*hl-PopupNotification*
58765879
PopupNotification
5877-
Popup window created with |popup_notification()|. If not
5878-
defined |hl-WarningMsg| is used.
5880+
Popup window created with |popup_notification()|. Linked to
5881+
|hl-WarningMsg| by default.
58795882
*hl-Question*
58805883
Question |hit-enter| prompt and yes/no questions.
58815884
*hl-QuickFixLine*

runtime/doc/tags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8191,6 +8191,7 @@ hl-PmenuSbar syntax.txt /*hl-PmenuSbar*
81918191
hl-PmenuSel syntax.txt /*hl-PmenuSel*
81928192
hl-PmenuThumb syntax.txt /*hl-PmenuThumb*
81938193
hl-PopupNotification syntax.txt /*hl-PopupNotification*
8194+
hl-PopupSelected syntax.txt /*hl-PopupSelected*
81948195
hl-Question syntax.txt /*hl-Question*
81958196
hl-QuickFixLine syntax.txt /*hl-QuickFixLine*
81968197
hl-Scrollbar syntax.txt /*hl-Scrollbar*

src/highlight.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ static char *(highlight_init_both[]) = {
262262
"default link PmenuMatchSel PmenuSel",
263263
"default link PmenuExtra Pmenu",
264264
"default link PmenuExtraSel PmenuSel",
265+
"default link PopupSelected PmenuSel",
266+
"default link MessageWindow WarningMsg",
267+
"default link PopupNotification WarningMsg",
265268
CENT("Normal cterm=NONE", "Normal gui=NONE"),
266269
NULL
267270
};

src/popupwin.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -696,9 +696,6 @@ popup_highlight_curline(win_T *wp)
696696
if (!sign_exists_by_name(sign_name))
697697
{
698698
char *linehl = "PopupSelected";
699-
700-
if (syn_name2id((char_u *)linehl) == 0)
701-
linehl = "PmenuSel";
702699
sign_define_by_name(sign_name, NULL, (char_u *)linehl, NULL, NULL, NULL,
703700
NULL, SIGN_DEF_PRIO);
704701
}
@@ -2006,10 +2003,8 @@ popup_update_color(win_T *wp, create_type_T type)
20062003
{
20072004
char *hiname = type == TYPE_MESSAGE_WIN
20082005
? "MessageWindow" : "PopupNotification";
2009-
int nr = syn_name2id((char_u *)hiname);
2010-
20112006
set_string_option_direct_in_win(wp, (char_u *)"wincolor", -1,
2012-
(char_u *)(nr == 0 ? "WarningMsg" : hiname),
2007+
(char_u *)hiname,
20132008
OPT_FREE|OPT_LOCAL, 0);
20142009
}
20152010

src/testdir/dumps/Test_popupwin_notify_02.dump

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
>1+0&#ffffff0| @7|╔+0#e000002&|═@21|╗| +0#0000000&@41
2-
|2| @7|║+0#e000002&| |f|i|r|s|t| |n|o|t|i|f|i|c|a|t|i|o|n| @2|║| +0#0000000&@41
3-
|3| @7|╚+0#e000002&|═@21|╝| +0#0000000&@41
1+
>1+0&#ffffff0| @7|╔+0&#5fd7ff255|═@21|╗| +0&#ffffff0@41
2+
|2| @7|║+0&#5fd7ff255| |f|i|r|s|t| |n|o|t|i|f|i|c|a|t|i|o|n| @2|║| +0&#ffffff0@41
3+
|3| @7|╚+0&#5fd7ff255|═@21|╝| +0&#ffffff0@41
44
|4| @7|╔+0&#5fd7ff255|═@31|╗| +0&#ffffff0@31
55
|5| @7|║+0&#5fd7ff255| |a|n|o|t|h|e|r| |i|m|p|o|r|t|a|n|t| |n|o|t|i|f|i|c|a|t|i|o|n| |║| +0&#ffffff0@31
66
|6| @7|╚+0&#5fd7ff255|═@31|╝| +0&#ffffff0@31

src/version.c

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

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
1123,
707709
/**/
708710
1122,
709711
/**/

0 commit comments

Comments
 (0)