feat(statusline): support multibyte fillchar

This includes a partial port of Vim patch 8.2.2569 and some changes to
nvim_eval_statusline() to allow a multibyte fillchar. Literally every
line of C code touched by that patch has been refactored in Nvim, and
that patch contains some irrelevant foldcolumn tests I'm not sure how to
port (as Nvim's foldcolumn behavior has diverged from Vim's).
This commit is contained in:
zeertzjq
2022-01-16 18:44:28 +08:00
parent 7085e5b0c8
commit be15ac06ba
8 changed files with 152 additions and 91 deletions

View File

@@ -2551,6 +2551,34 @@ describe('API', function()
'Should be truncated%<',
{ maxwidth = 15 }))
end)
it('supports ASCII fillchar', function()
eq({ str = 'a~~~b', width = 5 },
meths.eval_statusline('a%=b', { fillchar = '~', maxwidth = 5 }))
end)
it('supports single-width multibyte fillchar', function()
eq({ str = 'a━━━b', width = 5 },
meths.eval_statusline('a%=b', { fillchar = '', maxwidth = 5 }))
end)
it('rejects double-width fillchar', function()
eq('fillchar must be a single-width character',
pcall_err(meths.eval_statusline, '', { fillchar = '' }))
end)
it('rejects control character fillchar', function()
eq('fillchar must be a single-width character',
pcall_err(meths.eval_statusline, '', { fillchar = '\a' }))
end)
it('rejects multiple-character fillchar', function()
eq('fillchar must be a single-width character',
pcall_err(meths.eval_statusline, '', { fillchar = 'aa' }))
end)
it('rejects empty string fillchar', function()
eq('fillchar must be a single-width character',
pcall_err(meths.eval_statusline, '', { fillchar = '' }))
end)
it('rejects non-string fillchar', function()
eq('fillchar must be a single-width character',
pcall_err(meths.eval_statusline, '', { fillchar = 1 }))
end)
describe('highlight parsing', function()
it('works', function()
eq({