mirror of
https://github.com/neovim/neovim.git
synced 2025-12-13 10:02:49 +00:00
fillchars: make checks more strict and improve tests
This commit is contained in:
@@ -180,7 +180,8 @@ Options:
|
|||||||
'cpoptions' flags: |cpo-_|
|
'cpoptions' flags: |cpo-_|
|
||||||
'display' flag `msgsep` to minimize scrolling when showing messages
|
'display' flag `msgsep` to minimize scrolling when showing messages
|
||||||
'guicursor' works in the terminal
|
'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
|
'inccommand' shows interactive results for |:substitute|-like commands
|
||||||
'scrollback'
|
'scrollback'
|
||||||
'statusline' supports unlimited alignment sections
|
'statusline' supports unlimited alignment sections
|
||||||
|
|||||||
@@ -3438,16 +3438,20 @@ static char_u *set_chars_option(char_u **varp)
|
|||||||
&& p[len] == ':'
|
&& p[len] == ':'
|
||||||
&& p[len + 1] != NUL) {
|
&& p[len + 1] != NUL) {
|
||||||
s = p + len + 1;
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
if (tab[i].cp == &lcs_tab2) {
|
if (tab[i].cp == &lcs_tab2) {
|
||||||
if (*s == NUL) {
|
if (*s == NUL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
c2 = mb_ptr2char_adv((const char_u **)&s);
|
int c2len = utf_ptr2len(s);
|
||||||
if (mb_char2cells(c2) > 1) {
|
c2 = mb_cptr2char_adv((const char_u **)&s);
|
||||||
|
if (mb_char2cells(c2) > 1 || (c2len == 1 && c2 > 127)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local Screen = require('test.functional.ui.screen')
|
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()
|
describe("'fillchars'", function()
|
||||||
local screen
|
local screen
|
||||||
@@ -15,8 +18,15 @@ describe("'fillchars'", function()
|
|||||||
screen:detach()
|
screen:detach()
|
||||||
end)
|
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()
|
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([[
|
screen:expect([[
|
||||||
^ |
|
^ |
|
||||||
~ |
|
~ |
|
||||||
@@ -24,22 +34,33 @@ describe("'fillchars'", function()
|
|||||||
~ |
|
~ |
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
execute('set fillchars+=eob:\\ ')
|
end)
|
||||||
|
it('supports whitespace', function()
|
||||||
|
command('set fillchars=eob:\\ ')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
^ |
|
^ |
|
||||||
|
|
|
|
||||||
|
|
|
|
||||||
|
|
|
|
||||||
:set fillchars+=eob:\ |
|
|
|
||||||
]])
|
]])
|
||||||
execute('set fillchars+=eob:ñ')
|
end)
|
||||||
|
it('supports multibyte char', function()
|
||||||
|
command('set fillchars=eob:ñ')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
^ |
|
^ |
|
||||||
ñ |
|
ñ |
|
||||||
ñ |
|
ñ |
|
||||||
ñ |
|
ñ |
|
||||||
:set fillchars+=eob:ñ |
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
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)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user