Skip to content

Commit c77534c

Browse files
committed
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 #7282)
1 parent b3a0194 commit c77534c

4 files changed

Lines changed: 43 additions & 8 deletions

File tree

src/getchar.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3691,11 +3691,7 @@ getcmdkeycmd(
36913691
else if (IS_SPECIAL(c1))
36923692
{
36933693
if (c1 == K_SNR)
3694-
{
3695-
ga_append(&line_ga, (char)K_SPECIAL);
3696-
ga_append(&line_ga, (char)KS_EXTRA);
3697-
ga_append(&line_ga, (char)KE_SNR);
3698-
}
3694+
ga_concat(&line_ga, (char_u *)"<SNR>");
36993695
else
37003696
{
37013697
semsg(e_cmd_maping_must_not_include_str_key,

src/ops.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3465,8 +3465,9 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
34653465
if ((redo_yank || oap->op_type != OP_YANK)
34663466
&& ((!VIsual_active || oap->motion_force)
34673467
// Also redo Operator-pending Visual mode mappings
3468-
|| (VIsual_active && cap->cmdchar == ':'
3469-
&& oap->op_type != OP_COLON))
3468+
|| (VIsual_active
3469+
&& (cap->cmdchar == ':' || cap->cmdchar == K_COMMAND)
3470+
&& oap->op_type != OP_COLON))
34703471
&& cap->cmdchar != 'D'
34713472
#ifdef FEAT_FOLDING
34723473
&& oap->op_type != OP_FOLD
@@ -3688,7 +3689,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
36883689
get_op_char(oap->op_type),
36893690
get_extra_op_char(oap->op_type),
36903691
oap->motion_force, cap->cmdchar, cap->nchar);
3691-
else if (cap->cmdchar != ':')
3692+
else if (cap->cmdchar != ':' && cap->cmdchar != K_COMMAND)
36923693
{
36933694
int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL;
36943695

src/testdir/test_mapping.vim

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,4 +1324,40 @@ func Test_map_cmdkey_cmdline_mode()
13241324
%bw!
13251325
endfunc
13261326

1327+
func Test_map_cmdkey_redo()
1328+
func SelectDash()
1329+
call search('^---\n\zs', 'bcW')
1330+
norm! V
1331+
call search('\n\ze---$', 'W')
1332+
endfunc
1333+
1334+
let text =<< trim END
1335+
---
1336+
aaa
1337+
---
1338+
bbb
1339+
bbb
1340+
---
1341+
ccc
1342+
ccc
1343+
ccc
1344+
---
1345+
END
1346+
new Xcmdtext
1347+
call setline(1, text)
1348+
1349+
onoremap <silent> i- <Cmd>call SelectDash()<CR>
1350+
call feedkeys('2Gdi-', 'xt')
1351+
call assert_equal(['---', '---'], getline(1, 2))
1352+
call feedkeys('j.', 'xt')
1353+
call assert_equal(['---', '---', '---'], getline(1, 3))
1354+
call feedkeys('j.', 'xt')
1355+
call assert_equal(['---', '---', '---', '---'], getline(1, 4))
1356+
1357+
bwipe!
1358+
call delete('Xcmdtext')
1359+
delfunc SelectDash
1360+
ounmap i-
1361+
endfunc
1362+
13271363
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2005,
753755
/**/
754756
2004,
755757
/**/

0 commit comments

Comments
 (0)