aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2021-09-20 08:42:18 -0700
committerGitHub <noreply@github.com>2021-09-20 08:42:18 -0700
commitf8e0011534a3f94cfd341fd9bfce1bcf9b1b7b73 (patch)
treecb57bbedc1537f7f47e1768c8ab8b9e6a527381c /src
parent7d67bd58655052103f3891122f0e6fe30ae1f829 (diff)
downloadrneovim-f8e0011534a3f94cfd341fd9bfce1bcf9b1b7b73.tar.gz
rneovim-f8e0011534a3f94cfd341fd9bfce1bcf9b1b7b73.tar.bz2
rneovim-f8e0011534a3f94cfd341fd9bfce1bcf9b1b7b73.zip
fix(inccommand): ignore trailing commands only for *previewed* command #15732
Since the `State` is global, other scripts are unexpectedly affected during the 'inccommand' preview. This commit introduces a new flag for `do_cmdline`, in order to ignore trailing '|'-separated commands only for the command invoking the preview. fix #8796, update #7494 Co-authored-by: itchyny <itchyny@hatena.ne.jp>
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c3
-rw-r--r--src/nvim/ex_docmd.h1
-rw-r--r--src/nvim/ex_getln.c2
3 files changed, 4 insertions, 2 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 27c98a13a6..0a485f97f0 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -303,6 +303,7 @@ int do_cmdline_cmd(const char *cmd)
/// DOCMD_KEYTYPED - Don't reset KeyTyped.
/// DOCMD_EXCRESET - Reset the exception environment (used for debugging).
/// DOCMD_KEEPLINE - Store first typed line (for repeating with ".").
+/// DOCMD_PREVIEW - During 'inccommand' preview.
///
/// @return FAIL if cmdline could not be executed, OK otherwise
int do_cmdline(char_u *cmdline, LineGetter fgetline,
@@ -601,7 +602,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline,
recursive--;
// Ignore trailing '|'-separated commands in preview-mode ('inccommand').
- if (State & CMDPREVIEW) {
+ if ((State & CMDPREVIEW) && (flags & DOCMD_PREVIEW)) {
next_cmdline = NULL;
}
diff --git a/src/nvim/ex_docmd.h b/src/nvim/ex_docmd.h
index f6bd2adcd5..28b8d22a56 100644
--- a/src/nvim/ex_docmd.h
+++ b/src/nvim/ex_docmd.h
@@ -11,6 +11,7 @@
#define DOCMD_KEYTYPED 0x08 // don't reset KeyTyped
#define DOCMD_EXCRESET 0x10 // reset exception environment (for debugging
#define DOCMD_KEEPLINE 0x20 // keep typed line for repeating with "."
+#define DOCMD_PREVIEW 0x40 // during 'inccommand' preview
/* defines for eval_vars() */
#define VALID_PATH 1
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index f63987136f..33c0097ba4 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2251,7 +2251,7 @@ static int command_line_changed(CommandLineState *s)
State |= CMDPREVIEW;
emsg_silent++; // Block error reporting as the command may be incomplete
msg_silent++; // Block messages, namely ones that prompt
- do_cmdline(ccline.cmdbuff, NULL, NULL, DOCMD_KEEPLINE|DOCMD_NOWAIT);
+ do_cmdline(ccline.cmdbuff, NULL, NULL, DOCMD_KEEPLINE|DOCMD_NOWAIT|DOCMD_PREVIEW);
msg_silent--; // Unblock messages
emsg_silent--; // Unblock error reporting