mirror of
https://github.com/neovim/neovim.git
synced 2025-09-24 12:08:33 +00:00
vim-patch:8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Problem: Redoing a mapping with <Cmd> doesn't work properly.
Solution: Fill the redo buffer. Use "<SNR>" instead of a key code.
(closes vim/vim#7282)
c77534c303
This commit is contained in:
@@ -4476,9 +4476,7 @@ char_u * getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat)
|
|||||||
aborted = true;
|
aborted = true;
|
||||||
} else if (IS_SPECIAL(c1)) {
|
} else if (IS_SPECIAL(c1)) {
|
||||||
if (c1 == K_SNR) {
|
if (c1 == K_SNR) {
|
||||||
ga_append(&line_ga, (char)K_SPECIAL);
|
ga_concat(&line_ga, (char_u *)"<SNR>");
|
||||||
ga_append(&line_ga, (char)KS_EXTRA);
|
|
||||||
ga_append(&line_ga, (char)KE_SNR);
|
|
||||||
} else {
|
} else {
|
||||||
EMSG2(e_cmdmap_key, get_special_key_name(c1, cmod));
|
EMSG2(e_cmdmap_key, get_special_key_name(c1, cmod));
|
||||||
aborted = true;
|
aborted = true;
|
||||||
|
@@ -1485,7 +1485,8 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
if ((redo_yank || oap->op_type != OP_YANK)
|
if ((redo_yank || oap->op_type != OP_YANK)
|
||||||
&& ((!VIsual_active || oap->motion_force)
|
&& ((!VIsual_active || oap->motion_force)
|
||||||
// Also redo Operator-pending Visual mode mappings.
|
// Also redo Operator-pending Visual mode mappings.
|
||||||
|| (cap->cmdchar == ':' && oap->op_type != OP_COLON))
|
|| ((cap->cmdchar == ':' || cap->cmdchar == K_COMMAND)
|
||||||
|
&& oap->op_type != OP_COLON))
|
||||||
&& cap->cmdchar != 'D'
|
&& cap->cmdchar != 'D'
|
||||||
&& oap->op_type != OP_FOLD
|
&& oap->op_type != OP_FOLD
|
||||||
&& oap->op_type != OP_FOLDOPEN
|
&& oap->op_type != OP_FOLDOPEN
|
||||||
@@ -1678,7 +1679,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
prep_redo(oap->regname, cap->count0,
|
prep_redo(oap->regname, cap->count0,
|
||||||
get_op_char(oap->op_type), get_extra_op_char(oap->op_type),
|
get_op_char(oap->op_type), get_extra_op_char(oap->op_type),
|
||||||
oap->motion_force, cap->cmdchar, cap->nchar);
|
oap->motion_force, cap->cmdchar, cap->nchar);
|
||||||
} else if (cap->cmdchar != ':') {
|
} else if (cap->cmdchar != ':' && cap->cmdchar != K_COMMAND) {
|
||||||
int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL;
|
int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL;
|
||||||
|
|
||||||
// reverse what nv_replace() did
|
// reverse what nv_replace() did
|
||||||
|
@@ -499,4 +499,40 @@ func Test_mapcomplete()
|
|||||||
call assert_match("abbr! \x01", @:)
|
call assert_match("abbr! \x01", @:)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_map_cmdkey_redo()
|
||||||
|
func SelectDash()
|
||||||
|
call search('^---\n\zs', 'bcW')
|
||||||
|
norm! V
|
||||||
|
call search('\n\ze---$', 'W')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
let text =<< trim END
|
||||||
|
---
|
||||||
|
aaa
|
||||||
|
---
|
||||||
|
bbb
|
||||||
|
bbb
|
||||||
|
---
|
||||||
|
ccc
|
||||||
|
ccc
|
||||||
|
ccc
|
||||||
|
---
|
||||||
|
END
|
||||||
|
new Xcmdtext
|
||||||
|
call setline(1, text)
|
||||||
|
|
||||||
|
onoremap <silent> i- <Cmd>call SelectDash()<CR>
|
||||||
|
call feedkeys('2Gdi-', 'xt')
|
||||||
|
call assert_equal(['---', '---'], getline(1, 2))
|
||||||
|
call feedkeys('j.', 'xt')
|
||||||
|
call assert_equal(['---', '---', '---'], getline(1, 3))
|
||||||
|
call feedkeys('j.', 'xt')
|
||||||
|
call assert_equal(['---', '---', '---', '---'], getline(1, 4))
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
call delete('Xcmdtext')
|
||||||
|
delfunc SelectDash
|
||||||
|
ounmap i-
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user