summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/_extui
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2025-05-07 10:02:53 +0200
committerGitHub <noreply@github.com>2025-05-07 10:02:53 +0200
commit6dee1672ccc973f50e28e4adb7cbadd481db3f03 (patch)
tree426940b23ba2a99f697a2bee5bfad46b77489fb0 /runtime/lua/vim/_extui
parent27311b0b5c152899c8bc7156dda28055b8431b76 (diff)
fix(extui): "box" window width calculated on last line (#33881)
Problem: The "box" window width is calculated on the last line when applying "last" virt_text. There may be longer lines part of the same message. Solution: Don't decrease box width if the calculated width is smaller. Minor unrelated changes. Co-authored-by: Eike <eike.rackwitz@mail.de>
Diffstat (limited to 'runtime/lua/vim/_extui')
-rw-r--r--runtime/lua/vim/_extui/messages.lua11
1 files changed, 6 insertions, 5 deletions
diff --git a/runtime/lua/vim/_extui/messages.lua b/runtime/lua/vim/_extui/messages.lua
index d6a4ebff84..b5ffe3f2d4 100644
--- a/runtime/lua/vim/_extui/messages.lua
+++ b/runtime/lua/vim/_extui/messages.lua
@@ -65,7 +65,7 @@ end
---
---@param type 'last'|'msg'
local function set_virttext(type)
- if type == 'last' and ext.cmdheight == 0 or M.virt.delayed then
+ if type == 'last' and (ext.cmdheight == 0 or M.virt.delayed) then
return
end
@@ -101,7 +101,8 @@ local function set_virttext(type)
local offset = tar ~= 'box' and 0
or api.nvim_win_get_position(win)[2] + (api.nvim_win_get_config(win).border and 1 or 0)
- M.box.width = math.min(o.columns, scol - offset + width)
+ -- Check if adding the virt_text on this line will exceed the current 'box' width.
+ M.box.width = math.max(M.box.width, math.min(o.columns, scol - offset + width))
if tar == 'box' and api.nvim_win_get_width(win) < M.box.width then
api.nvim_win_set_width(win, M.box.width)
end
@@ -122,7 +123,7 @@ local function set_virttext(type)
local pad = o.columns - width ---@type integer
local newlines = math.max(0, ext.cmdheight - h.all)
row = row + newlines
- M.cmd.last_col = newlines > 0 and o.columns or mode > 0 and 0 or o.columns - width
+ M.cmd.last_col = mode > 0 and 0 or o.columns - (newlines > 0 and 0 or width)
if newlines > 0 then
-- Add empty lines to place virt_text on the last screen row.
@@ -179,9 +180,9 @@ function M.show_msg(tar, content, replace_last, more)
msg = msg .. chunk[2]
end
- -- Check if messages that should be sent to more prompt exceeds maximum newlines.
+ -- Check if message that should be sent to more prompt exceeds maximum newlines.
local max = (tar == 'cmd' and ext.cmdheight or math.ceil(o.lines * 0.5))
- if more and select(2, msg:gsub('\n', '')) > max then
+ if more and select(2, msg:gsub('\n', '')) >= max then
M.msg_history_show({ { 'spill', content } })
return
end