aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_core
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2026-07-15 08:13:37 -0400
committerGitHub <noreply@github.com>2026-07-15 08:13:37 -0400
commit31ad7d45274bb7b79e0cbc6a67fc69a80bb28c89 (patch)
treebb5650699f55b1fa725934ca1e9710b626dd3e94 /runtime/lua/vim/_core
parent6f370f34f2c24aed0d2acebab23c4bcc86a06d69 (diff)
parent5e5cd87aa6a63d2cc38426c2f44e43662717abe0 (diff)
downloadrneovim-31ad7d45274bb7b79e0cbc6a67fc69a80bb28c89.tar.gz
rneovim-31ad7d45274bb7b79e0cbc6a67fc69a80bb28c89.tar.bz2
rneovim-31ad7d45274bb7b79e0cbc6a67fc69a80bb28c89.zip
Merge #40621 fix(ui2)!: legacy 'ruler' inconsistencies
Diffstat (limited to 'runtime/lua/vim/_core')
-rw-r--r--runtime/lua/vim/_core/ui2/messages.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/runtime/lua/vim/_core/ui2/messages.lua b/runtime/lua/vim/_core/ui2/messages.lua
index aa3888635b..922c05c44b 100644
--- a/runtime/lua/vim/_core/ui2/messages.lua
+++ b/runtime/lua/vim/_core/ui2/messages.lua
@@ -126,7 +126,7 @@ local function set_virttext(type, tgt)
})
local row = texth.end_row
local col = fn.virtcol2col(win, row + 1, texth.end_vcol)
- local scol = fn.screenpos(win, row + 1, col).col ---@type integer
+ local scol = fn.screenpos(win, row + 1, col).endcol ---@type integer
if type ~= 'last' then
-- Calculate at which column to place the virt_text such that it is at the end
@@ -179,7 +179,8 @@ local function set_virttext(type, tgt)
-- Crop text on last screen row and find byte offset to place mark at.
local vcol = texth.end_vcol - (scol - M.cmd.last_col)
- col = vcol <= 0 and 0 or fn.virtcol2col(win, row + 1, vcol)
+ col = vcol <= 0 and 0 or fn.virtcol2col(win, row + 1, vcol + 1) - 1
+ scol = fn.screenpos(win, row + 1, col).endcol
M.cmd.prev_msg = mode > 0 and '' or M.cmd.prev_msg
M.virt.cmd = mode > 0 and { {}, {} } or M.virt.cmd
api.nvim_buf_set_text(ui.bufs.cmd, row, col, row, -1, { mode > 0 and ' ' or '' })
@@ -389,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.
@@ -462,6 +470,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