From 78292dcc3d0e94d1413af8f2417227377ca5dc26 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 12 Dec 2025 23:40:11 -0500 Subject: [PATCH] vim-patch:8.2.4636: not using Visual range Problem: Not using Visual range. Solution: Put the command pointer back to the range. https://github.com/vim/vim/commit/1501b63f8dedbd15ee5bfd9a177e558ffdf0673a Co-authored-by: Bram Moolenaar --- src/nvim/ex_docmd.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 8c5f1b74f1..24dcc76b19 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2761,14 +2761,19 @@ int parse_command_modifiers(exarg_T *eap, const char **errormsg, cmdmod_T *cmod, break; } - if (has_visual_range && eap->cmd > cmd_start) { - // Move the '<,'> range to after the modifiers and insert a colon. - // Since the modifiers have been parsed put the colon on top of the - // space: "'<,'>mod cmd" -> "mod:'<,'>cmd - // Put eap->cmd after the colon. - memmove(cmd_start - 5, cmd_start, (size_t)(eap->cmd - cmd_start)); - eap->cmd -= 5; - memmove(eap->cmd - 1, ":'<,'>", 6); + if (has_visual_range) { + if (eap->cmd > cmd_start) { + // Move the '<,'> range to after the modifiers and insert a colon. + // Since the modifiers have been parsed put the colon on top of the + // space: "'<,'>mod cmd" -> "mod:'<,'>cmd + // Put eap->cmd after the colon. + memmove(cmd_start - 5, cmd_start, (size_t)(eap->cmd - cmd_start)); + eap->cmd -= 5; + memmove(eap->cmd - 1, ":'<,'>", 6); + } else { + // no modifiers, move the pointer back + eap->cmd -= 5; + } } return OK;