feat(api): relax statusline fillchar width check

Treat fillchar as single-width even if it isn't.
This commit is contained in:
zeertzjq
2022-03-10 07:18:49 +08:00
parent a978d7689d
commit 3011794c86
2 changed files with 14 additions and 13 deletions

View File

@@ -2621,24 +2621,24 @@ describe('API', 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 = '' }))
it('treats double-width fillchar as single-width', function()
eq({ str = 'a哦哦哦b', width = 5 },
meths.eval_statusline('a%=b', { fillchar = '', maxwidth = 5 }))
end)
it('rejects control character fillchar', function()
eq('fillchar must be a single-width character',
pcall_err(meths.eval_statusline, '', { fillchar = '\a' }))
it('treats control character fillchar as single-width', function()
eq({ str = 'a\031\031\031b', width = 5 },
meths.eval_statusline('a%=b', { fillchar = '\031', maxwidth = 5 }))
end)
it('rejects multiple-character fillchar', function()
eq('fillchar must be a single-width character',
eq('fillchar must be a single character',
pcall_err(meths.eval_statusline, '', { fillchar = 'aa' }))
end)
it('rejects empty string fillchar', function()
eq('fillchar must be a single-width character',
eq('fillchar must be a single character',
pcall_err(meths.eval_statusline, '', { fillchar = '' }))
end)
it('rejects non-string fillchar', function()
eq('fillchar must be a single-width character',
eq('fillchar must be a single character',
pcall_err(meths.eval_statusline, '', { fillchar = 1 }))
end)
describe('highlight parsing', function()