mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.1516: cannot use special keys in <Cmd> mapping
Problem: Cannot use special keys in <Cmd> mapping.
Solution: Do allow for special keys in <Cmd> and <ScriptCmd> mappings.
(closes vim/vim#12326)
3ab3a86481
This commit is contained in:
parent
29c228dc10
commit
3233137813
@ -554,6 +554,21 @@ void AppendToRedobuffLit(const char *str, int len)
|
||||
}
|
||||
}
|
||||
|
||||
/// Append "s" to the redo buffer, leaving 3-byte special key codes unmodified
|
||||
/// and escaping other K_SPECIAL bytes.
|
||||
void AppendToRedobuffSpec(const char *s)
|
||||
{
|
||||
while (*s != NUL) {
|
||||
if ((uint8_t)(*s) == K_SPECIAL && s[1] != NUL && s[2] != NUL) {
|
||||
// Insert special key literally.
|
||||
add_buff(&redobuff, s, 3L);
|
||||
s += 3;
|
||||
} else {
|
||||
add_char_buff(&redobuff, mb_cptr2char_adv(&s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Append a character to the redo buffer.
|
||||
/// Translates special keys, NUL, K_SPECIAL and multibyte characters.
|
||||
void AppendCharToRedobuff(int c)
|
||||
@ -2927,11 +2942,6 @@ char *getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat)
|
||||
}
|
||||
c1 = TO_SPECIAL(c1, c2);
|
||||
}
|
||||
if (c1 == Ctrl_V) {
|
||||
// CTRL-V is followed by octal, hex or other characters, reverses
|
||||
// what AppendToRedobuffLit() does.
|
||||
c1 = get_literal(true);
|
||||
}
|
||||
|
||||
if (got_int) {
|
||||
aborted = true;
|
||||
|
@ -5858,7 +5858,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
||||
if (repeat_cmdline == NULL) {
|
||||
ResetRedobuff();
|
||||
} else {
|
||||
AppendToRedobuffLit(repeat_cmdline, -1);
|
||||
AppendToRedobuffSpec(repeat_cmdline);
|
||||
AppendToRedobuff(NL_STR);
|
||||
XFREE_CLEAR(repeat_cmdline);
|
||||
}
|
||||
|
@ -979,10 +979,6 @@ func Test_map_cmdkey()
|
||||
call assert_fails('call feedkeys("\<F3>", "xt")', 'E1136:')
|
||||
call assert_equal(0, x)
|
||||
|
||||
noremap <F3> <Cmd><F3>let x = 2<CR>
|
||||
call assert_fails('call feedkeys("\<F3>", "xt")', 'E1137:')
|
||||
call assert_equal(0, x)
|
||||
|
||||
noremap <F3> <Cmd>let x = 3
|
||||
call assert_fails('call feedkeys("\<F3>", "xt!")', 'E1255:')
|
||||
call assert_equal(0, x)
|
||||
@ -1084,11 +1080,6 @@ func Test_map_cmdkey()
|
||||
unmap <F3>
|
||||
unmap! <F3>
|
||||
%bw!
|
||||
|
||||
" command line ending in "0" is handled without errors
|
||||
onoremap ix <cmd>eval 0<cr>
|
||||
call feedkeys('dix.', 'xt')
|
||||
ounmap ix
|
||||
endfunc
|
||||
|
||||
" text object enters visual mode
|
||||
@ -1475,6 +1466,24 @@ func Test_map_cmdkey_redo()
|
||||
call delete('Xcmdtext')
|
||||
delfunc SelectDash
|
||||
ounmap i-
|
||||
|
||||
new
|
||||
call setline(1, 'aaa bbb ccc ddd')
|
||||
|
||||
" command can contain special keys
|
||||
onoremap ix <Cmd>let g:foo ..= '…'<Bar>normal! <C-Right><CR>
|
||||
let g:foo = ''
|
||||
call feedkeys('0dix.', 'xt')
|
||||
call assert_equal('……', g:foo)
|
||||
call assert_equal('ccc ddd', getline(1))
|
||||
unlet g:foo
|
||||
|
||||
" command line ending in "0" is handled without errors
|
||||
onoremap ix <Cmd>eval 0<CR>
|
||||
call feedkeys('dix.', 'xt')
|
||||
|
||||
ounmap ix
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" Test for using <script> with a map to remap characters in rhs
|
||||
|
Loading…
Reference in New Issue
Block a user