From f9f3b464dda319288b8ce592e53f0d9cf9ca8b4e Mon Sep 17 00:00:00 2001 From: Pedro Gabriel de Morais Ribeiro <52004811+pedrog14@users.noreply.github.com> Date: Sat, 15 Feb 2025 14:34:17 -0300 Subject: fix(ui): reposition window if border is different than "none" (#1859) Co-authored-by: William Boman --- lua/mason-core/ui/display.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lua/mason-core/ui/display.lua b/lua/mason-core/ui/display.lua index c4aebd95..3b616085 100644 --- a/lua/mason-core/ui/display.lua +++ b/lua/mason-core/ui/display.lua @@ -170,13 +170,10 @@ M._render_node = render_node ---@alias WindowOpts { effects?: table, winhighlight?: string[], border?: string|table } ----@param size integer | float +---@param size number ---@param viewport integer local function calc_size(size, viewport) - if size <= 1 then - return math.ceil(size * viewport) - end - return math.min(size, viewport) + return size > 1 and math.min(size, viewport) or math.floor(size * viewport) end ---@param opts WindowOpts @@ -188,6 +185,11 @@ local function create_popup_window_opts(opts, sizes_only) local width = calc_size(settings.current.ui.width, columns) local row = math.floor((lines - height) / 2) local col = math.floor((columns - width) / 2) + if opts.border ~= "none" then + row = math.max(row - 1, 0) + col = math.max(col - 1, 0) + end + local popup_layout = { height = height, width = width, -- cgit v1.2.3-70-g09d2