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)
			
			
This commit is contained in:
		| @ -3691,11 +3691,7 @@ getcmdkeycmd( | |||||||
| 	else if (IS_SPECIAL(c1)) | 	else if (IS_SPECIAL(c1)) | ||||||
| 	{ | 	{ | ||||||
| 	    if (c1 == K_SNR) | 	    if (c1 == K_SNR) | ||||||
| 	    { | 		ga_concat(&line_ga, (char_u *)"<SNR>"); | ||||||
| 		ga_append(&line_ga, (char)K_SPECIAL); |  | ||||||
| 		ga_append(&line_ga, (char)KS_EXTRA); |  | ||||||
| 		ga_append(&line_ga, (char)KE_SNR); |  | ||||||
| 	    } |  | ||||||
| 	    else | 	    else | ||||||
| 	    { | 	    { | ||||||
| 		semsg(e_cmd_maping_must_not_include_str_key, | 		semsg(e_cmd_maping_must_not_include_str_key, | ||||||
|  | |||||||
| @ -3465,8 +3465,9 @@ do_pending_operator(cmdarg_T *cap, int old_col, int 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 | ||||||
| 		    || (VIsual_active && cap->cmdchar == ':' | 		    || (VIsual_active | ||||||
| 						 && oap->op_type != OP_COLON)) | 			  && (cap->cmdchar == ':' || cap->cmdchar == K_COMMAND) | ||||||
|  | 						  && oap->op_type != OP_COLON)) | ||||||
| 		&& cap->cmdchar != 'D' | 		&& cap->cmdchar != 'D' | ||||||
| #ifdef FEAT_FOLDING | #ifdef FEAT_FOLDING | ||||||
| 		&& oap->op_type != OP_FOLD | 		&& oap->op_type != OP_FOLD | ||||||
| @ -3688,7 +3689,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) | |||||||
| 			    get_op_char(oap->op_type), | 			    get_op_char(oap->op_type), | ||||||
| 			    get_extra_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; | ||||||
|  |  | ||||||
|  | |||||||
| @ -1324,4 +1324,40 @@ func Test_map_cmdkey_cmdline_mode() | |||||||
|   %bw! |   %bw! | ||||||
| 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 | ||||||
|  | |||||||
| @ -750,6 +750,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 */ | ||||||
|  | /**/ | ||||||
|  |     2005, | ||||||
| /**/ | /**/ | ||||||
|     2004, |     2004, | ||||||
| /**/ | /**/ | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user