From a26cdcb20e68f38f636b14a03c3f9657f5c74f67 Mon Sep 17 00:00:00 2001 From: tao <2471314@gmail.com> Date: Tue, 12 Aug 2025 06:39:03 +0800 Subject: [PATCH] fix(inccommand): skip input() during preview #35272 Problem: During preview, the `input` still prompts the user to enter something that won't be used later, which could be a bit confusing. e.g., `:s/a/\=input("")`. Solution: Make the input() return early during 'inccommand' preview. --- src/nvim/ex_getln.c | 4 ++++ test/functional/ui/inccommand_spec.lua | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 3c4e90f69d..56e34cb485 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4819,6 +4819,10 @@ void get_user_input(const typval_T *const argvars, typval_T *const rettv, const rettv->v_type = VAR_STRING; rettv->vval.v_string = NULL; + if (cmdpreview) { + return; + } + const char *prompt; const char *defstr = ""; typval_T *cancelreturn = NULL; diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 37dc0f5195..7f976ca5a4 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -2937,3 +2937,15 @@ it("'inccommand' disables preview if preview buffer can't be created #27086", fu ]]) eq('nosplit', api.nvim_get_option_value('inccommand', {})) end) + +it(':substitute with inccommand, does not show prompt during preview #11940', function() + clear() + local screen = Screen.new(30, 3) + common_setup(screen, 'split', 'foo') + feed([[:s/f/\=input("sub: ")]]) + screen:expect([[ + oo | + {1:~ }| + :s/f/\=input("sub: ")^ | + ]]) +end)