Skip to content

Commit 049def7

Browse files
committed
fix: don't enforce window height for full-height vsplit quickfix
1 parent e4fb0b1 commit 049def7

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

lua/quicker/init.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ end
140140
---Open the quickfix or loclist window.
141141
---@param opts? quicker.OpenOpts
142142
M.open = function(opts)
143+
local util = require("quicker.util")
143144
---@type {loclist: boolean, focus: boolean, height?: integer, min_height: integer, max_height: integer, open_cmd_mods?: quicker.OpenCmdMods}
144145
opts = vim.tbl_deep_extend("keep", opts or {}, {
145146
loclist = false,
@@ -161,8 +162,11 @@ M.open = function(opts)
161162
height = #vim.fn.getqflist()
162163
end
163164

164-
height = math.min(opts.max_height, math.max(opts.min_height, height))
165-
vim.api.nvim_win_set_height(0, height)
165+
-- only set the height if the quickfix is not a full-height vsplit
166+
if not util.is_full_height_vsplit(0) then
167+
height = math.min(opts.max_height, math.max(opts.min_height, height))
168+
vim.api.nvim_win_set_height(0, height)
169+
end
166170

167171
if not opts.focus then
168172
vim.cmd.wincmd({ args = { "p" } })

lua/quicker/util.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,25 @@ M.get_lnum_extmarks = function(bufnr, lnum, line_len, ns)
7171
end, extmarks)
7272
end
7373

74+
---Return true if the window is a full-height leaf window
75+
---@param winid? integer
76+
---@return boolean
77+
M.is_full_height_vsplit = function(winid)
78+
if not winid or winid == 0 then
79+
winid = vim.api.nvim_get_current_win()
80+
end
81+
local layout = vim.fn.winlayout()
82+
-- If the top layout is not vsplit, then it's not a vertical leaf
83+
if layout[1] ~= "row" then
84+
return false
85+
end
86+
for _, v in ipairs(layout[2]) do
87+
if v[1] == "leaf" and v[2] == winid then
88+
return true
89+
end
90+
end
91+
92+
return false
93+
end
94+
7495
return M

0 commit comments

Comments
 (0)