opacity_blank = TRUE;
// Keep the underlying character and blend its foreground color
// from popup background color to original color.
+ // Combine the popup window color with the character's own
+ // attribute (e.g. match highlight) so that its background
+ // color is preserved on blank cells.
+ int char_attr = ScreenAttrs[off_from];
int popup_attr = get_wcr_attr(screen_opacity_popup);
+ int combined = hl_combine_attr(popup_attr, char_attr);
int blend = screen_opacity_popup->w_popup_blend;
ScreenAttrs[off_to] = hl_blend_attr(ScreenAttrs[off_to],
- popup_attr, blend, TRUE);
+ combined, blend, TRUE);
screen_char(off_to, row, col + coloff);
// For wide background character, also update the second cell.
if (bg_char_cells == 2)
&& (flags & SLF_POPUP)
&& screen_opacity_popup->w_popup_blend > 0)
{
+ int char_attr = ScreenAttrs[off_from];
int popup_attr = get_wcr_attr(screen_opacity_popup);
int blend = screen_opacity_popup->w_popup_blend;
- // Blend popup attr with default background (0)
- // FALSE = keep popup foreground color, blend background only
- ScreenAttrs[off_to] = hl_blend_attr(0, popup_attr, blend, FALSE);
+ // Combine popup window color with the character's own
+ // attribute (e.g. syntax highlighting) so that the
+ // character's foreground color is preserved.
+ int combined = hl_combine_attr(popup_attr, char_attr);
+ ScreenAttrs[off_to] = hl_blend_attr(0, combined, blend, FALSE);
}
#endif
--- /dev/null
+>1+0&#ffffff0| @73
+|2| @73
+|3| @7|f+0#ff404010#5fd7ff255|o@1| @1|b+0#0000000&|a|r| +0&#ffffff0@57
+|4| @7|b+0fd7ff255|a|z| @4| +0&#ffffff0@57
+|5| @73
+|6| @73
+|7| @73
+|8| @73
+|9| @73
+@57|1|,|1| @10|T|o|p|
--- /dev/null
+>1+0&#ffffff0| @73
+|2| @73
+|3| @7|f+0#ff404010#5fd7ff255|o@1| @1|b+0#0000000&|a|r| +0&#ffffff0@57
+|4| @7|b+0fd7ff255|a|z| @4| +0&#ffffff0@57
+|5| @73
+|6| @73
+|7| @73
+|8| @73
+|9| @73
+|:| @55|1|,|1| @10|T|o|p|
call StopVimInTerminal(buf)
endfunc
+func Test_popup_opacity_highlight()
+ CheckScreendump
+
+ " Verify that match highlighting is preserved when opacity < 100,
+ " both for non-blank characters and trailing blank cells.
+ let lines =<< trim END
+ call setline(1, range(1, 100))
+ hi PopupColor ctermbg=lightblue
+ hi MyHl ctermfg=red
+
+ " 'foo ' includes trailing spaces to test the opacity blank path.
+ let winid = popup_create(['foo bar', 'baz'],
+ \ #{line: 3, col: 10, highlight: 'PopupColor', opacity: 100})
+ call win_execute(winid, "call matchadd('MyHl', 'foo ')")
+ END
+ call writefile(lines, 'XtestPopupOpacity', 'D')
+ let buf = RunVimInTerminal('-S XtestPopupOpacity', #{rows: 10})
+ call VerifyScreenDump(buf, 'Test_popupwin_opacity_hl_100', {})
+
+ " opacity=80: highlighted text should still be visible
+ call term_sendkeys(buf, ":call popup_clear()\<CR>")
+ call TermWait(buf)
+ call term_sendkeys(buf, ":let winid = popup_create(['foo bar', 'baz'],"
+ \ .. " #{line: 3, col: 10, highlight: 'PopupColor', opacity: 80})\<CR>")
+ call TermWait(buf)
+ call term_sendkeys(buf, ":call win_execute(winid,"
+ \ .. " \"call matchadd('MyHl', 'foo ')\")\<CR>")
+ call TermWait(buf)
+ call term_sendkeys(buf, ":\<CR>")
+ call VerifyScreenDump(buf, 'Test_popupwin_opacity_hl_80', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_popup_getwininfo_tabnr()
tab split
let winid1 = popup_create('sup', #{tabpage: 1})
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 35,
/**/
34,
/**/