Skip to content

Commit f9f3b46

Browse files
fix(ui): reposition window if border is different than "none" (#1859)
Co-authored-by: William Boman <[email protected]>
1 parent 5664dd5 commit f9f3b46

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lua/mason-core/ui/display.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,10 @@ M._render_node = render_node
170170

171171
---@alias WindowOpts { effects?: table<string, fun()>, winhighlight?: string[], border?: string|table }
172172

173-
---@param size integer | float
173+
---@param size number
174174
---@param viewport integer
175175
local function calc_size(size, viewport)
176-
if size <= 1 then
177-
return math.ceil(size * viewport)
178-
end
179-
return math.min(size, viewport)
176+
return size > 1 and math.min(size, viewport) or math.floor(size * viewport)
180177
end
181178

182179
---@param opts WindowOpts
@@ -188,6 +185,11 @@ local function create_popup_window_opts(opts, sizes_only)
188185
local width = calc_size(settings.current.ui.width, columns)
189186
local row = math.floor((lines - height) / 2)
190187
local col = math.floor((columns - width) / 2)
188+
if opts.border ~= "none" then
189+
row = math.max(row - 1, 0)
190+
col = math.max(col - 1, 0)
191+
end
192+
191193
local popup_layout = {
192194
height = height,
193195
width = width,

0 commit comments

Comments
 (0)