mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fillchars: make checks more strict and improve tests
This commit is contained in:
parent
a7bb63c55d
commit
5442f0b622
@ -180,7 +180,8 @@ Options:
|
||||
'cpoptions' flags: |cpo-_|
|
||||
'display' flag `msgsep` to minimize scrolling when showing messages
|
||||
'guicursor' works in the terminal
|
||||
'fillchars' flag `msgsep` (see 'display' above)
|
||||
'fillchars' flags: `msgsep` (see 'display' above)
|
||||
and `eob` for |EndOfBuffer| marker
|
||||
'inccommand' shows interactive results for |:substitute|-like commands
|
||||
'scrollback'
|
||||
'statusline' supports unlimited alignment sections
|
||||
|
@ -3438,16 +3438,20 @@ static char_u *set_chars_option(char_u **varp)
|
||||
&& p[len] == ':'
|
||||
&& p[len + 1] != NUL) {
|
||||
s = p + len + 1;
|
||||
c1 = mb_ptr2char_adv((const char_u **)&s);
|
||||
if (mb_char2cells(c1) > 1) {
|
||||
|
||||
// TODO(bfredl): use schar_T representation and utfc_ptr2len
|
||||
int c1len = utf_ptr2len(s);
|
||||
c1 = mb_cptr2char_adv((const char_u **)&s);
|
||||
if (mb_char2cells(c1) > 1 || (c1len == 1 && c1 > 127)) {
|
||||
continue;
|
||||
}
|
||||
if (tab[i].cp == &lcs_tab2) {
|
||||
if (*s == NUL) {
|
||||
continue;
|
||||
}
|
||||
c2 = mb_ptr2char_adv((const char_u **)&s);
|
||||
if (mb_char2cells(c2) > 1) {
|
||||
int c2len = utf_ptr2len(s);
|
||||
c2 = mb_cptr2char_adv((const char_u **)&s);
|
||||
if (mb_char2cells(c2) > 1 || (c2len == 1 && c2 > 127)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
local clear, execute = helpers.clear, helpers.execute
|
||||
local clear, command = helpers.clear, helpers.command
|
||||
local eval = helpers.eval
|
||||
local eq = helpers.eq
|
||||
local exc_exec = helpers.exc_exec
|
||||
|
||||
describe("'fillchars'", function()
|
||||
local screen
|
||||
@ -15,8 +18,15 @@ describe("'fillchars'", function()
|
||||
screen:detach()
|
||||
end)
|
||||
|
||||
local function shouldfail(val,errval)
|
||||
errval = errval or val
|
||||
eq('Vim(set):E474: Invalid argument: fillchars='..errval,
|
||||
exc_exec('set fillchars='..val))
|
||||
end
|
||||
|
||||
describe('"eob" flag', function()
|
||||
it('renders empty lines at the end of the buffer with eob', function()
|
||||
it("uses '~' by default", function()
|
||||
eq('', eval('&fillchars'))
|
||||
screen:expect([[
|
||||
^ |
|
||||
~ |
|
||||
@ -24,22 +34,33 @@ describe("'fillchars'", function()
|
||||
~ |
|
||||
|
|
||||
]])
|
||||
execute('set fillchars+=eob:\\ ')
|
||||
end)
|
||||
it('supports whitespace', function()
|
||||
command('set fillchars=eob:\\ ')
|
||||
screen:expect([[
|
||||
^ |
|
||||
|
|
||||
|
|
||||
|
|
||||
:set fillchars+=eob:\ |
|
||||
|
|
||||
]])
|
||||
execute('set fillchars+=eob:ñ')
|
||||
end)
|
||||
it('supports multibyte char', function()
|
||||
command('set fillchars=eob:ñ')
|
||||
screen:expect([[
|
||||
^ |
|
||||
ñ |
|
||||
ñ |
|
||||
ñ |
|
||||
:set fillchars+=eob:ñ |
|
||||
|
|
||||
]])
|
||||
end)
|
||||
it('handles invalid values', function()
|
||||
shouldfail('eob:') -- empty string
|
||||
shouldfail('eob:馬') -- doublewidth char
|
||||
shouldfail('eob:å̲') -- composing chars
|
||||
shouldfail('eob:xy') -- two ascii chars
|
||||
shouldfail('eob:\255', 'eob:<ff>') -- invalid UTF-8
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user