mirror of
https://github.com/vim/vim.git
synced 2025-09-30 04:44:14 -04:00
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Problem: mapset() does not restore <Nop> mapping properly. Solution: Use an empty string for <Nop>. (closes #11022)
This commit is contained in:
@@ -2658,7 +2658,10 @@ f_mapset(typval_T *argvars, typval_T *rettv UNUSED)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
orig_rhs = rhs;
|
orig_rhs = rhs;
|
||||||
rhs = replace_termcodes(rhs, &arg_buf,
|
if (STRICMP(rhs, "<nop>") == 0) // "<Nop>" means nothing
|
||||||
|
rhs = (char_u *)"";
|
||||||
|
else
|
||||||
|
rhs = replace_termcodes(rhs, &arg_buf,
|
||||||
REPTERM_DO_LT | REPTERM_SPECIAL, NULL);
|
REPTERM_DO_LT | REPTERM_SPECIAL, NULL);
|
||||||
|
|
||||||
noremap = dict_get_number(d, "noremap") ? REMAP_NONE: 0;
|
noremap = dict_get_number(d, "noremap") ? REMAP_NONE: 0;
|
||||||
|
@@ -183,11 +183,11 @@ func Test_range_map()
|
|||||||
call assert_equal("abcd", getline(1))
|
call assert_equal("abcd", getline(1))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func One_mapset_test(keys)
|
func One_mapset_test(keys, rhs)
|
||||||
exe 'nnoremap ' .. a:keys .. ' original<CR>'
|
exe 'nnoremap ' .. a:keys .. ' ' .. a:rhs
|
||||||
let orig = maparg(a:keys, 'n', 0, 1)
|
let orig = maparg(a:keys, 'n', 0, 1)
|
||||||
call assert_equal(a:keys, orig.lhs)
|
call assert_equal(a:keys, orig.lhs)
|
||||||
call assert_equal('original<CR>', orig.rhs)
|
call assert_equal(a:rhs, orig.rhs)
|
||||||
call assert_equal('n', orig.mode)
|
call assert_equal('n', orig.mode)
|
||||||
|
|
||||||
exe 'nunmap ' .. a:keys
|
exe 'nunmap ' .. a:keys
|
||||||
@@ -197,15 +197,16 @@ func One_mapset_test(keys)
|
|||||||
call mapset('n', 0, orig)
|
call mapset('n', 0, orig)
|
||||||
let d = maparg(a:keys, 'n', 0, 1)
|
let d = maparg(a:keys, 'n', 0, 1)
|
||||||
call assert_equal(a:keys, d.lhs)
|
call assert_equal(a:keys, d.lhs)
|
||||||
call assert_equal('original<CR>', d.rhs)
|
call assert_equal(a:rhs, d.rhs)
|
||||||
call assert_equal('n', d.mode)
|
call assert_equal('n', d.mode)
|
||||||
|
|
||||||
exe 'nunmap ' .. a:keys
|
exe 'nunmap ' .. a:keys
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_mapset()
|
func Test_mapset()
|
||||||
call One_mapset_test('K')
|
call One_mapset_test('K', 'original<CR>')
|
||||||
call One_mapset_test('<F3>')
|
call One_mapset_test('<F3>', 'original<CR>')
|
||||||
|
call One_mapset_test('<F3>', '<lt>Nop>')
|
||||||
|
|
||||||
" Check <> key conversion
|
" Check <> key conversion
|
||||||
new
|
new
|
||||||
@@ -228,6 +229,26 @@ func Test_mapset()
|
|||||||
|
|
||||||
iunmap K
|
iunmap K
|
||||||
|
|
||||||
|
" Test that <Nop> is restored properly
|
||||||
|
inoremap K <Nop>
|
||||||
|
call feedkeys("SK\<Esc>", 'xt')
|
||||||
|
call assert_equal('', getline(1))
|
||||||
|
|
||||||
|
let orig = maparg('K', 'i', 0, 1)
|
||||||
|
call assert_equal('K', orig.lhs)
|
||||||
|
call assert_equal('<Nop>', orig.rhs)
|
||||||
|
call assert_equal('i', orig.mode)
|
||||||
|
|
||||||
|
inoremap K foo
|
||||||
|
call feedkeys("SK\<Esc>", 'xt')
|
||||||
|
call assert_equal('foo', getline(1))
|
||||||
|
|
||||||
|
call mapset('i', 0, orig)
|
||||||
|
call feedkeys("SK\<Esc>", 'xt')
|
||||||
|
call assert_equal('', getline(1))
|
||||||
|
|
||||||
|
iunmap K
|
||||||
|
|
||||||
" Test literal <CR> using a backslash
|
" Test literal <CR> using a backslash
|
||||||
let cpo_save = &cpo
|
let cpo_save = &cpo
|
||||||
set cpo-=B
|
set cpo-=B
|
||||||
|
@@ -707,6 +707,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
341,
|
||||||
/**/
|
/**/
|
||||||
340,
|
340,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user