diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 6af136bb5a..5c93128f25 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -262,6 +262,10 @@ These existing features changed their behavior. more emoji characters than before, including those encoded with multiple emoji codepoints combined with ZWJ (zero width joiner) codepoints. +• Text in the 'statusline', 'tabline', and 'winbar' now inherits highlights + from the respective |hl-StatusLine|, |hl-TabLine|, and |hl-WinBar| highlight + groups. + • |vim.on_key()| callbacks won't be invoked recursively when a callback itself consumes input. diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 07bb7dd69a..6b8f5e27a3 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -430,7 +430,7 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler) if (hltab[n].userhl == 0) { curattr = attr; } else if (hltab[n].userhl < 0) { - curattr = syn_id2attr(-hltab[n].userhl); + curattr = hl_combine_attr(attr, syn_id2attr(-hltab[n].userhl)); } else if (wp != NULL && wp != curwin && wp->w_status_height != 0) { curattr = highlight_stlnc[hltab[n].userhl - 1]; } else { diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 87d66fa604..47b923c8e2 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -1691,6 +1691,7 @@ describe("'winhighlight' highlight", function() [29] = { foreground = Screen.colors.Blue1, background = Screen.colors.Red, bold = true }, [30] = { background = tonumber('0xff8800') }, [31] = { background = tonumber('0xff8800'), bold = true, foreground = Screen.colors.Blue }, + [32] = { bold = true, reverse = true, background = Screen.colors.DarkGreen }, } command('hi Background1 guibg=DarkBlue') command('hi Background2 guibg=DarkGreen') @@ -2253,10 +2254,10 @@ describe("'winhighlight' highlight", function() some text | more tex^t | {0:~ }| - {3:[No Name] }{1:2,9 All}| + {3:[No Name] }{11:2,9 All}| some text | more text | - {4:[No Name] }{1:1,1 All}| + {4:[No Name] }{14:1,1 All}| | ]], } @@ -2267,10 +2268,10 @@ describe("'winhighlight' highlight", function() some text | more tex^t | {0:~ }| - {3:[No Name] }{5:2,9 All}| + {3:[No Name] }{32:2,9 All}| some text | more text | - {4:[No Name] }{1:1,1 All}| + {4:[No Name] }{14:1,1 All}| | ]], } @@ -2281,10 +2282,10 @@ describe("'winhighlight' highlight", function() some tex^t | more text | {0:~ }| - {3:[No Name] }{5:1,9 All}| + {3:[No Name] }{32:1,9 All}| some text | more text | - {4:[No Name] }{1:1,1 All}| + {4:[No Name] }{14:1,1 All}| | ]], } diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua index f16f750ea1..3728ec8dbc 100644 --- a/test/functional/ui/multibyte_spec.lua +++ b/test/functional/ui/multibyte_spec.lua @@ -474,26 +474,42 @@ describe('multibyte rendering: statusline', function() end) it('emoji with ZWJ in filename with custom stl', function() + screen:add_extra_attr_ids { + [100] = { + bold = true, + reverse = true, + foreground = Screen.colors.Gray100, + background = Screen.colors.Red, + }, + } command('set statusline=xx%#ErrorMsg#%f%##yy') command('file 🧑‍💻') screen:expect { grid = [[ ^ | {1:~ }| - {3:xx}{9:🧑‍💻}{3:yy }| + {3:xx}{100:🧑‍💻}{3:yy }| | ]], } end) it('unprintable chars in filename with custom stl', function() + screen:add_extra_attr_ids { + [100] = { + bold = true, + reverse = true, + foreground = Screen.colors.Gray100, + background = Screen.colors.Red, + }, + } command('set statusline=xx%#ErrorMsg#%f%##yy') command('file 🧑​💻') screen:expect { grid = [[ ^ | {1:~ }| - {3:xx}{9:🧑<200b>💻}{3:yy }| + {3:xx}{100:🧑<200b>💻}{3:yy }| | ]], } diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 937e709d66..001d927cb1 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -27,6 +27,7 @@ for _, model in ipairs(mousemodels) do screen:set_default_attr_ids({ [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText [1] = { bold = true, reverse = true }, -- StatusLine + [2] = { bold = true, foreground = Screen.colors.Blue, reverse = true }, -- NonText combined with StatusLine }) screen:attach() command('set laststatus=2 mousemodel=' .. model) @@ -87,7 +88,7 @@ for _, model in ipairs(mousemodels) do grid = [[ ^ | {0:~ }|*5 - {1:^I}{0:^A^I^A^I}{1:^A }| + {1:^I}{2:^A^I^A^I}{1:^A }| | ]], } diff --git a/test/functional/ui/tabline_spec.lua b/test/functional/ui/tabline_spec.lua index 5cda70df21..de1e701101 100644 --- a/test/functional/ui/tabline_spec.lua +++ b/test/functional/ui/tabline_spec.lua @@ -125,6 +125,26 @@ describe('tabline', function() } end) + it('combines highlight attributes', function() + screen:set_default_attr_ids({ + [1] = { foreground = Screen.colors.Blue1, bold = true }, -- StatusLine + [2] = { bold = true, italic = true }, -- StatusLine + [3] = { bold = true, italic = true, foreground = Screen.colors.Red }, -- NonText combined with StatusLine + }) + command('hi TabLineFill gui=bold,italic') + command('hi Identifier guifg=red') + command('set tabline=Test%#Identifier#here') + command('set showtabline=2') + screen:expect { + grid = [[ + {2:Test}{3:here }| + ^ | + {1:~ }|*2 + | + ]], + } + end) + it('click definitions do not leak memory #21765', function() command('set tabline=%@MyClickFunc@MyClickText%T') command('set showtabline=2') diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua index fb907026a5..bbdf3ad9ba 100644 --- a/test/functional/ui/winbar_spec.lua +++ b/test/functional/ui/winbar_spec.lua @@ -40,6 +40,16 @@ describe('winbar', function() bold = true, foreground = Screen.colors.Magenta, }, + [12] = { + underline = true, + background = Screen.colors.Red, + }, + [13] = { + underline = true, + bold = true, + foreground = Screen.colors.Blue, + background = Screen.colors.Red, + }, }) api.nvim_set_option_value('winbar', 'Set Up The Bars', {}) end) @@ -182,6 +192,18 @@ describe('winbar', function() ]]) end) + it('works with combined highlight attributes', function() + command('hi Winbar guibg=red gui=underline') + command('hi Identifier guifg=blue gui=bold') + command('set winbar=Lookatmy%#Identifier#highlights') + screen:expect([[ + {12:Lookatmy}{13:highlights }| + ^ | + {3:~ }|*10 + | + ]]) + end) + it('can be ruler', function() insert [[ just some