From efd0fa55c8b1ba78692382c52a9d644fdd5488c8 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Tue, 24 Jun 2025 16:37:51 +0200 Subject: [PATCH] fix(cmdline): validate 'incsearch' cursor for "cmdline_show" redraw (#34630) Problem: "cmdline_show" event may be emitted with an invalid cursor position, causing a redraw that will clear the match highlight. Solution: Mark the cursor position as valid so that a "cmdline_show" callback that updates the screen does not clear the match highlight. --- src/nvim/ex_getln.c | 1 + test/functional/ui/cmdline2_spec.lua | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 95737d95bb..d7dcae4c57 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -556,6 +556,7 @@ static void may_do_incsearch_highlighting(int firstc, int count, incsearch_state curwin->w_cursor = s->search_start; } else if (found != 0) { curwin->w_cursor = end_pos; + curwin->w_valid_cursor = end_pos; // mark as valid for cmdline_show redraw } msg_starthere(); diff --git a/test/functional/ui/cmdline2_spec.lua b/test/functional/ui/cmdline2_spec.lua index e13ef89183..f2d0a28f5a 100644 --- a/test/functional/ui/cmdline2_spec.lua +++ b/test/functional/ui/cmdline2_spec.lua @@ -43,4 +43,15 @@ describe('cmdline2', function() ]]) n.assert_alive() end) + + it("redraw does not clear 'incsearch' highlight with conceal", function() + exec('call setline(1, ["foo", "foobar"]) | set conceallevel=1 concealcursor=c') + feed('/foo') + screen:expect([[ + {10:foo} | + {2:foo}bar | + {1:~ }|*11 + /foo^ | + ]]) + end) end)