mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
mbyte: Fix crash when using multibyte chars in maparg() return (#6986)
This is a refactoring typo from #6947. Fixes #6985 Combined with #6947 where typo was made it also fixes vim/vim#1827 which was present in Neovim.
This commit is contained in:
parent
619838f85d
commit
702c94aacf
@ -1780,7 +1780,7 @@ const char *mb_unescape(const char **const pp)
|
||||
// Return a multi-byte character if it's found. An illegal sequence
|
||||
// will result in a 1 here.
|
||||
if (utf_ptr2len((const char_u *)buf) > 1) {
|
||||
*pp = (const char *)str + buf_idx + 1;
|
||||
*pp = (const char *)str + str_idx + 1;
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
|
||||
local clear = helpers.clear
|
||||
local eq = helpers.eq
|
||||
local eval = helpers.eval
|
||||
local funcs = helpers.funcs
|
||||
local nvim = helpers.nvim
|
||||
local source = helpers.source
|
||||
local command = helpers.command
|
||||
|
||||
describe('maparg()', function()
|
||||
before_each(clear)
|
||||
@ -117,4 +118,42 @@ describe('maparg()', function()
|
||||
eq(1, map_dict['expr'])
|
||||
eq('i', map_dict['mode'])
|
||||
end)
|
||||
|
||||
it('works with combining characters', function()
|
||||
-- Using addacutes to make combining character better visible
|
||||
local function ac(s)
|
||||
local acute = '\204\129' -- U+0301 COMBINING ACUTE ACCENT
|
||||
local ret = s:gsub('`', acute)
|
||||
return ret
|
||||
end
|
||||
command(ac([[
|
||||
nnoremap a b`
|
||||
nnoremap c` d
|
||||
nnoremap e` f`
|
||||
]]))
|
||||
eq(ac('b`'), funcs.maparg(ac('a')))
|
||||
eq(ac(''), funcs.maparg(ac('c')))
|
||||
eq(ac('d'), funcs.maparg(ac('c`')))
|
||||
eq(ac('f`'), funcs.maparg(ac('e`')))
|
||||
|
||||
local function acmap(lhs, rhs)
|
||||
return {
|
||||
lhs = ac(lhs),
|
||||
rhs = ac(rhs),
|
||||
|
||||
buffer = 0,
|
||||
expr = 0,
|
||||
mode = 'n',
|
||||
noremap = 1,
|
||||
nowait = 0,
|
||||
sid = 0,
|
||||
silent = 0,
|
||||
}
|
||||
end
|
||||
|
||||
eq({}, funcs.maparg(ac('c'), 'n', 0, 1))
|
||||
eq(acmap('a', 'b`'), funcs.maparg(ac('a'), 'n', 0, 1))
|
||||
eq(acmap('c`', 'd'), funcs.maparg(ac('c`'), 'n', 0, 1))
|
||||
eq(acmap('e`', 'f`'), funcs.maparg(ac('e`'), 'n', 0, 1))
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user