Skip to content

Commit

Permalink
fix: don't enforce window height for full-height vsplit quickfix
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Jan 16, 2025
1 parent e4fb0b1 commit 049def7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lua/quicker/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ end
---Open the quickfix or loclist window.
---@param opts? quicker.OpenOpts
M.open = function(opts)
local util = require("quicker.util")
---@type {loclist: boolean, focus: boolean, height?: integer, min_height: integer, max_height: integer, open_cmd_mods?: quicker.OpenCmdMods}
opts = vim.tbl_deep_extend("keep", opts or {}, {
loclist = false,
Expand All @@ -161,8 +162,11 @@ M.open = function(opts)
height = #vim.fn.getqflist()
end

height = math.min(opts.max_height, math.max(opts.min_height, height))
vim.api.nvim_win_set_height(0, height)
-- only set the height if the quickfix is not a full-height vsplit
if not util.is_full_height_vsplit(0) then
height = math.min(opts.max_height, math.max(opts.min_height, height))
vim.api.nvim_win_set_height(0, height)
end

if not opts.focus then
vim.cmd.wincmd({ args = { "p" } })
Expand Down
21 changes: 21 additions & 0 deletions lua/quicker/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,25 @@ M.get_lnum_extmarks = function(bufnr, lnum, line_len, ns)
end, extmarks)
end

---Return true if the window is a full-height leaf window
---@param winid? integer
---@return boolean
M.is_full_height_vsplit = function(winid)
if not winid or winid == 0 then
winid = vim.api.nvim_get_current_win()
end
local layout = vim.fn.winlayout()
-- If the top layout is not vsplit, then it's not a vertical leaf
if layout[1] ~= "row" then
return false
end
for _, v in ipairs(layout[2]) do
if v[1] == "leaf" and v[2] == winid then
return true
end
end

return false
end

return M

0 comments on commit 049def7

Please sign in to comment.