Skip to content

Commit f0e11d3

Browse files
girishjichrisbra
authored andcommitted
patch 9.1.1874: short-description
Problem: PMenuShadow overrides highlighting attributes (Maxim Kim) Solution: Use hl_combine_attr() to combine popup attribute with shadow attribute (Girish Palya) fixes: #18557 closes: #18634 Signed-off-by: Girish Palya <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 842c778 commit f0e11d3

File tree

5 files changed

+58
-4
lines changed

5 files changed

+58
-4
lines changed

src/popupmenu.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,16 +2234,19 @@ pum_draw_border(void)
22342234
}
22352235

22362236
/*
2237-
* Get the underlying character and redraw with shadow highlight
2237+
* Get the underlying character and redraw with shadow highlight.
2238+
* Preserve bold, italic, underline, and reverse text underneath the shadow.
22382239
*/
22392240
void
22402241
put_shadow_char(int row, int col)
22412242
{
22422243
char_u buf[MB_MAXBYTES + 1];
2243-
int attr = highlight_attr[HLF_PMS];
2244+
int shadow_attr = highlight_attr[HLF_PMS];
2245+
int char_attr, new_attr;
22442246

2245-
screen_getbytes(row, col, buf, NULL);
2246-
screen_putchar((*mb_ptr2char)(buf), row, col, attr);
2247+
screen_getbytes(row, col, buf, &char_attr);
2248+
new_attr = hl_combine_attr(char_attr, shadow_attr);
2249+
screen_putchar((*mb_ptr2char)(buf), row, col, new_attr);
22472250
}
22482251

22492252
/*
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
>b+2&#ffffff0|o|l|d| +0&&|i+12&&|t|a|l|i|c| +0&&|u+12&&|n|d|e|r|l|i|n|e| +0&&|r+1&&|e|v|e|r|s|e| +0&&|n|o|r|m|a|l| @38
2+
|b+0#0000001#ffd7ff255|o|l|d| @10|e+12#0000000#ffffff0| +0&&|r+1&&|e|v|e|r|s|e| +0&&|n|o|r|m|a|l| |b+2&&|o|l|d| +0&&@38
3+
|i+0#0000001#ffd7ff255|t|a|l|i|c| @8|s+1#6c6c6c255#0000001|e| +0#0000000#ffffff0|n|o|r|m|a|l| |b+2&&|o|l|d| +0&&|i+12&&|t|a|l|i|c| +0&&@38
4+
|u+0#0000001#ffd7ff255|n|d|e|r|l|i|n|e| @5|b+2#6c6c6c255#0000001|o|l+2#0000000#ffffff0|d| +0&&|i+12&&|t|a|l|i|c| +0&&|u+12&&|n|d|e|r|l|i|n|e| +0&&@38
5+
|r+0#0000001#ffd7ff255|e|v|e|r|s|e| @7|l+12#6c6c6c255#0000001|i|c+12#0000000#ffffff0| +0&&|u+12&&|n|d|e|r|l|i|n|e| +0&&|r+1&&|e|v|e|r|s|e| +0&&@38
6+
|n+0#0000001#ffd7ff255|o|r|m|a|l| @8| +0#6c6c6c255#0000001@1| +0#4040ff13#ffffff0@57
7+
|~| | +0#6c6c6c255#0000001@14| +0#4040ff13#ffffff0@57
8+
|~| @73
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
|b+2&#ffffff0|o|l|d| +0&&|i+12&&|t|a|l|i|c| +0&&>u+12&&|n|d|e|r|l|i|n|e| +0&&|r+1&&|e|v|e|r|s|e| +0&&|n|o|r|m|a|l| @38
2+
|i+12&&|t|a|l|i|c| +0&&|u+12&&|n|d|e| +0#0000001#ffd7ff255|u|n|d|e|r|l|i|n|e| @5|r+0#0000000#ffffff0|m|a|l| |b+2&&|o|l|d| +0&&@38
3+
|u+12&&|n|d|e|r|l|i|n|e| +0&&|r+1&&| +0#0000001#ffd7ff255|r|e|v|e|r|s|e| @7|l+2#6c6c6c255#0000001|d| +0#0000000#ffffff0|i+12&&|t|a|l|i|c| +0&&@38
4+
|r+1&&|e|v|e|r|s|e| +0&&|n|o|r| +0#0000001#ffd7ff255|n|o|r|m|a|l| @8|u+12#6c6c6c255#0000001|n|d+12#0000000#ffffff0|e|r|l|i|n|e| +0&&@38
5+
|n|o|r|m|a|l| |b+2&&|o|l|d| +0#0000001#ffd7ff255|i|t|a|l|i|c| @8|e+12#6c6c6c255#0000001| +0&&|r+1#0000000#ffffff0|e|v|e|r|s|e| +0&&@38
6+
|~+0#4040ff13&| @9| +0#0000001#ffd7ff255|b|o|l|d| @10| +0#6c6c6c255#0000001@1| +0#4040ff13#ffffff0@45
7+
|~| @11| +0#6c6c6c255#0000001@15| +0#4040ff13#ffffff0@45
8+
|~| @73

src/testdir/test_popup.vim

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,4 +2385,37 @@ func Test_popup_border()
23852385
call StopVimInTerminal(buf)
23862386
endfunc
23872387

2388+
func Test_popup_shadow_hiddenchar()
2389+
CheckScreendump
2390+
2391+
let lines =<< trim END
2392+
bold italic underline reverse normal
2393+
italic underline reverse normal bold
2394+
underline reverse normal bold italic
2395+
reverse normal bold italic underline
2396+
normal bold italic underline reverse
2397+
END
2398+
call writefile(lines, 'Xtest', 'D')
2399+
let buf = RunVimInTerminal('Xtest', {'cols': 75})
2400+
2401+
call term_sendkeys(buf, ":set completeopt=menuone,noselect pumborder=shadow\<CR>")
2402+
call term_sendkeys(buf, ":hi BoldGrp cterm=bold\<CR>")
2403+
call term_sendkeys(buf, ":hi ItalicGrp cterm=italic,underline\<CR>")
2404+
call term_sendkeys(buf, ":hi ReverseGrp cterm=reverse\<CR>")
2405+
call term_sendkeys(buf, ":call matchadd(\"BoldGrp\", \"bold\")\<CR>")
2406+
call term_sendkeys(buf, ":call matchadd(\"ItalicGrp\", \"italic\")\<CR>")
2407+
call term_sendkeys(buf, ":call matchadd(\"ItalicGrp\", \"underline\")\<CR>")
2408+
call term_sendkeys(buf, ":call matchadd(\"ReverseGrp\", \"reverse\")\<CR>")
2409+
2410+
call term_sendkeys(buf, "i\<C-N>")
2411+
call TermWait(buf, 10)
2412+
call VerifyScreenDump(buf, 'Test_popup_shadow_hiddenchar_1', {'rows': 8})
2413+
call term_sendkeys(buf, "\<Esc>wwi\<C-N>")
2414+
call TermWait(buf, 10)
2415+
call VerifyScreenDump(buf, 'Test_popup_shadow_hiddenchar_2', {'rows': 8})
2416+
call term_sendkeys(buf, "\<Esc>")
2417+
2418+
call StopVimInTerminal(buf)
2419+
endfunc
2420+
23882421
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

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

730730
static int included_patches[] =
731731
{ /* Add new patch number below this line */
732+
/**/
733+
1874,
732734
/**/
733735
1873,
734736
/**/

0 commit comments

Comments
 (0)