diff --git a/runtime/lua/vim/_core/ui2/messages.lua b/runtime/lua/vim/_core/ui2/messages.lua index 4182fd573b..7a6bd6e4c0 100644 --- a/runtime/lua/vim/_core/ui2/messages.lua +++ b/runtime/lua/vim/_core/ui2/messages.lua @@ -390,6 +390,13 @@ function M.show_msg(tgt, kind, content, replace_last, append, id) M.virt[tgt][M.virt.idx.dupe][1] = dupe > 0 and { 0, ('(%d)'):format(dupe) } or nil M.virt[tgt][M.virt.idx.spill][1] = tgt == 'cmd' and M.virt.cmd[M.virt.idx.spill][1] or nil set_virttext(tgt --[[@as 'cmd'|'msg']], tgt) + if tgt == 'cmd' then + -- make sure repeated long messages are cropped to keep the ruler intact + -- (if this is not scheduled, it breaks messages during textlock) + vim.schedule(function() + set_virttext('last', 'cmd') + end) + end end -- Reset message state the next event loop iteration. diff --git a/test/functional/ui/messages2_spec.lua b/test/functional/ui/messages2_spec.lua index 334b42365d..30acb62925 100644 --- a/test/functional/ui/messages2_spec.lua +++ b/test/functional/ui/messages2_spec.lua @@ -1200,6 +1200,15 @@ describe('messages2', function() -----------------------------------0,0-1 All| ]]) feed('') + -- message with repetition indicator keeps ruler intact + command('echo "-"->repeat(&columns)') + command('echo "-"->repeat(&columns)') + screen:expect([[ + ^ | + {1:~ }|*12 + --------------------------------(1)0,0-1 All| + ]]) + feed('') -- when the ruler is configured smaller, there is more space for messages command('set rulerformat=%l | redraw | echo "-"->repeat(&columns)') screen:expect([[