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)