fix(float): title/footer shows printable control chars #40047

Problem:
Literal tab (or other control char) in a float title/footer is
not made printable, so it renders incorrectly instead of as "^I".

Solution:
Normalize title/footer text for display like 'statusline'
tab to "^I", parameterize parse_virt_text() with untab
and recompute the width.
This commit is contained in:
glepnir
2026-05-30 22:02:16 +08:00
committed by GitHub
parent a9ef076817
commit 70cfeabe23
5 changed files with 58 additions and 29 deletions

View File

@@ -3056,6 +3056,45 @@ describe('float window', function()
eq({ { '🦄', '' }, { 'BB', { 'B0', 'B1', '' } } }, api.nvim_win_get_config(win).title)
eq({ { '🦄', '' }, { 'BB', { 'B0', 'B1', '' } } }, api.nvim_win_get_config(win).footer)
api.nvim_win_set_config(win, { border = 'single', title = 'a\tb', footer = 'A\tB' })
if multigrid then
screen:expect({
grid = [[
## grid 1
[2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
^ |
{0:~ }|*5
## grid 3
|
## grid 4
{5:┌}{11:a^Ib}{5:─────┐}|
{5:│}{1: halloj! }{5:│}|
{5:│}{1: BORDAA }{5:│}|
{5:└}{11:A^IB}{5:─────┘}|
]],
float_pos = { [4] = { 1001, 'NW', 1, 2, 5, true, 50, 1, 2, 5 } },
win_viewport = {
[2] = { win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0 },
[4] = { win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0 },
},
})
else
screen:expect([[
^ |
{0:~ }|
{0:~ }{5:┌}{11:a^Ib}{5:─────┐}{0: }|
{0:~ }{5:│}{1: halloj! }{5:│}{0: }|
{0:~ }{5:│}{1: BORDAA }{5:│}{0: }|
{0:~ }{5:└}{11:A^IB}{5:─────┘}{0: }|
|
]])
end
api.nvim_win_set_config(win, { title = { { 'a\tb' } }, footer = { { 'A\tB' } } })
screen:expect_unchanged()
-- making it a split should not leak memory
api.nvim_win_set_config(win, { vertical = true })
if multigrid then