diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2026-07-15 08:13:37 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-15 08:13:37 -0400 |
| commit | 31ad7d45274bb7b79e0cbc6a67fc69a80bb28c89 (patch) | |
| tree | bb5650699f55b1fa725934ca1e9710b626dd3e94 /runtime/lua/vim | |
| parent | 6f370f34f2c24aed0d2acebab23c4bcc86a06d69 (diff) | |
| parent | 5e5cd87aa6a63d2cc38426c2f44e43662717abe0 (diff) | |
| download | rneovim-31ad7d45274bb7b79e0cbc6a67fc69a80bb28c89.tar.gz rneovim-31ad7d45274bb7b79e0cbc6a67fc69a80bb28c89.tar.bz2 rneovim-31ad7d45274bb7b79e0cbc6a67fc69a80bb28c89.zip | |
Merge #40621 fix(ui2)!: legacy 'ruler' inconsistencies
Diffstat (limited to 'runtime/lua/vim')
| -rw-r--r-- | runtime/lua/vim/_core/ui2/messages.lua | 13 | ||||
| -rw-r--r-- | runtime/lua/vim/_meta/options.gen.lua | 7 | ||||
| -rw-r--r-- | runtime/lua/vim/_meta/vvars.gen.lua | 2 |
3 files changed, 19 insertions, 3 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 diff --git a/runtime/lua/vim/_meta/options.gen.lua b/runtime/lua/vim/_meta/options.gen.lua index e7296cea5d..7b76ddbdc4 100644 --- a/runtime/lua/vim/_meta/options.gen.lua +++ b/runtime/lua/vim/_meta/options.gen.lua @@ -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 = "" diff --git a/runtime/lua/vim/_meta/vvars.gen.lua b/runtime/lua/vim/_meta/vvars.gen.lua index 3bc819b5a1..0154045f20 100644 --- a/runtime/lua/vim/_meta/vvars.gen.lua +++ b/runtime/lua/vim/_meta/vvars.gen.lua @@ -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 |