Merge #40621 fix(ui2)!: legacy 'ruler' inconsistencies

This commit is contained in:
Justin M. Keyes
2026-07-15 08:13:37 -04:00
committed by GitHub
16 changed files with 208 additions and 42 deletions

View File

@@ -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

View File

@@ -5380,6 +5380,13 @@ vim.go.ru = vim.go.ruler
--- set rulerformat=%15(%c%V\ %p%%%)
--- ```
---
--- This looks like an item group, but there are some differences in this
--- particular case. Most notably, the width is fixed and not a minimum,
--- and the ruler is left-aligned, whereas the alignment of item groups is
--- configurable and right-aligned by default.
---
--- When `ui2` is enabled, the ruler no longer has a fixed width and the
--- item group syntax has no special meaning for 'rulerformat'.
---
--- @type string
vim.o.rulerformat = ""

View File

@@ -129,7 +129,7 @@ vim.v.dying = ...
--- Number of screen cells that can be used for an `:echo` message
--- in the last screen line before causing the `hit-enter` prompt
--- (or "overflow" with `ui2`).
--- (no longer applicable when `ui2` is enabled).
---
--- Depends on 'showcmd', 'ruler' and 'columns'. You need to
--- check 'cmdheight' for whether there are full-width lines