From fcc391d89a2a30b02c3ba25a6351d37cdcd79e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Hoffmann?= Date: Sun, 5 Jul 2026 11:06:46 +0200 Subject: [PATCH] fix(ui2): clear showcmd virt_text together with search count Problem: when the search count is displayed, the showcmd virt_text is set to 11 empty spaces to ensure a consistent distance between search count and ruler, or screen edge in case of noruler. But when the search count is removed to make place for a message, the empty dummy showcmd remains and unnecessarily erases part of the message. Solution: properly remove showcmd together with search count. --- runtime/lua/vim/_core/ui2/messages.lua | 1 + test/functional/ui/messages2_spec.lua | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/runtime/lua/vim/_core/ui2/messages.lua b/runtime/lua/vim/_core/ui2/messages.lua index 07dc9c205a..1961084c38 100644 --- a/runtime/lua/vim/_core/ui2/messages.lua +++ b/runtime/lua/vim/_core/ui2/messages.lua @@ -462,6 +462,7 @@ function M.msg_show(kind, content, replace_last, _, append, id, trigger) M.cmd.last_emsg = (kind == 'emsg' or kind == 'wmsg') and os.time() or M.cmd.last_emsg -- Should clear the search count now, mark itself is cleared by invalidate. M.virt.last[M.virt.idx.search][1] = nil + M.virt.last[M.virt.idx.cmd] = {} end -- When message was emitted below an already expanded cmdline, move and route to pager. tgt = ui.cmd.expand > 0 and 'pager' or tgt diff --git a/test/functional/ui/messages2_spec.lua b/test/functional/ui/messages2_spec.lua index d3018f6727..7fbee747fa 100644 --- a/test/functional/ui/messages2_spec.lua +++ b/test/functional/ui/messages2_spec.lua @@ -1092,14 +1092,15 @@ describe('messages2', function() end) it('search count is cleared', function() - command('set ruler shortmess-=S | call setline(1, ["foo", "bar"])') + command('set ruler showcmd shortmess-=S | call setline(1, ["foo", "bar"])') feed('/foo') - screen:expect([[ + local search_count = [[ {10:^foo} | bar | {1:~ }|*11 /foo W [1/1] 1,1 All| - ]]) + ]] + screen:expect(search_count) feed('j') screen:expect([[ {10:foo} | @@ -1107,5 +1108,14 @@ describe('messages2', function() {1:~ }|*11 2,1 All| ]]) + feed('n') + screen:expect(search_count) + command('echo "-"->repeat(&columns)') + screen:expect([[ + {10:^foo} | + bar | + {1:~ }|*11 + -----------------------------------1,1 All| + ]]) end) end)