Skip to content

Commit

Permalink
feat(window): allow setting width/height a size for splits. either wi…
Browse files Browse the repository at this point in the history
…ll be used based on position
  • Loading branch information
folke committed May 30, 2024
1 parent 745b3f7 commit e8ee9b0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lua/trouble/view/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local Util = require("trouble.util")
---@class trouble.Window.split
---@field type "split"
---@field relative "editor" | "win" cursor is only valid for float
---@field size number
---@field size number | {width:number, height:number} when a table is provided, either the width or height is used based on the position
---@field position "top" | "bottom" | "left" | "right"

---@class trouble.Window.float
Expand Down Expand Up @@ -266,6 +266,9 @@ function M:mount_split(opts)
end
local parent_size = self:parent_size()
local size = opts.size
if type(size) == "table" then
size = opts.position == "left" or opts.position == "right" and size.width or size.height
end
if size <= 1 then
local vertical = opts.position == "left" or opts.position == "right"
size = math.floor(parent_size[vertical and "width" or "height"] * size)
Expand Down

0 comments on commit e8ee9b0

Please sign in to comment.