comparison src/normal.c @ 22862:6d50182e7e24 v8.2.1978

patch 8.2.1978: making a mapping work in all modes is complicated Commit: https://github.com/vim/vim/commit/957cf67d50516ba98716f59c9e1cb6412ec1535d Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 12 14:21:06 2020 +0100 patch 8.2.1978: making a mapping work in all modes is complicated Problem: Making a mapping work in all modes is complicated. Solution: Add the <Cmd> special key. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/7282, closes 4784, based on patch by Bjorn Linse)
author Bram Moolenaar <Bram@vim.org>
date Thu, 12 Nov 2020 14:30:04 +0100
parents f7f2d73ff85e
children d10a37eb91ee
comparison
equal deleted inserted replaced
22861:459c4d8b3a34 22862:6d50182e7e24
373 #ifdef FEAT_DND 373 #ifdef FEAT_DND
374 {K_DROP, nv_drop, NV_STS, 0}, 374 {K_DROP, nv_drop, NV_STS, 0},
375 #endif 375 #endif
376 {K_CURSORHOLD, nv_cursorhold, NV_KEEPREG, 0}, 376 {K_CURSORHOLD, nv_cursorhold, NV_KEEPREG, 0},
377 {K_PS, nv_edit, 0, 0}, 377 {K_PS, nv_edit, 0, 0},
378 {K_COMMAND, nv_colon, 0, 0},
378 }; 379 };
379 380
380 // Number of commands in nv_cmds[]. 381 // Number of commands in nv_cmds[].
381 #define NV_CMDS_SIZE (sizeof(nv_cmds) / sizeof(struct nv_cmd)) 382 #define NV_CMDS_SIZE (sizeof(nv_cmds) / sizeof(struct nv_cmd))
382 383
3310 * Handle a ":" command. 3311 * Handle a ":" command.
3311 */ 3312 */
3312 static void 3313 static void
3313 nv_colon(cmdarg_T *cap) 3314 nv_colon(cmdarg_T *cap)
3314 { 3315 {
3315 int old_p_im; 3316 int old_p_im;
3316 int cmd_result; 3317 int cmd_result;
3317 3318 int is_cmdkey = cap->cmdchar == K_COMMAND;
3318 if (VIsual_active) 3319
3320 if (VIsual_active && !is_cmdkey)
3319 nv_operator(cap); 3321 nv_operator(cap);
3320 else 3322 else
3321 { 3323 {
3322 if (cap->oap->op_type != OP_NOP) 3324 if (cap->oap->op_type != OP_NOP)
3323 { 3325 {
3324 // Using ":" as a movement is characterwise exclusive. 3326 // Using ":" as a movement is characterwise exclusive.
3325 cap->oap->motion_type = MCHAR; 3327 cap->oap->motion_type = MCHAR;
3326 cap->oap->inclusive = FALSE; 3328 cap->oap->inclusive = FALSE;
3327 } 3329 }
3328 else if (cap->count0) 3330 else if (cap->count0 && !is_cmdkey)
3329 { 3331 {
3330 // translate "count:" into ":.,.+(count - 1)" 3332 // translate "count:" into ":.,.+(count - 1)"
3331 stuffcharReadbuff('.'); 3333 stuffcharReadbuff('.');
3332 if (cap->count0 > 1) 3334 if (cap->count0 > 1)
3333 { 3335 {
3341 compute_cmdrow(); 3343 compute_cmdrow();
3342 3344
3343 old_p_im = p_im; 3345 old_p_im = p_im;
3344 3346
3345 // get a command line and execute it 3347 // get a command line and execute it
3346 cmd_result = do_cmdline(NULL, getexline, NULL, 3348 cmd_result = do_cmdline(NULL, is_cmdkey ? getcmdkeycmd : getexline, NULL,
3347 cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0); 3349 cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0);
3348 3350
3349 // If 'insertmode' changed, enter or exit Insert mode 3351 // If 'insertmode' changed, enter or exit Insert mode
3350 if (p_im != old_p_im) 3352 if (p_im != old_p_im)
3351 { 3353 {