Skip to content

Commit 2e122bf

Browse files
Copilotsand4rt
andauthored
Merge branch 'main' into fix-open-in-small-window
Co-authored-by: sand4rt <17591696+sand4rt@users.noreply.github.com>
2 parents 8c35776 + cc7306e commit 2e122bf

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎lua/zen/init.lua‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ local function reposition_stack(position)
281281
heights[win] = vim.api.nvim_win_get_height(win)
282282
end
283283

284+
-- Some Neovim versions raise `E242: Can't split a window while closing
285+
-- another` when this runs from a handler that fires midway through a window
286+
-- close (e.g. `WinClosed` recreating a side buffer, whose `BufWinEnter`
287+
-- reaches here before the original close has unwound). Guard the splits so
288+
-- that refusal cannot abort the surrounding close handler; the reposition is
289+
-- re-run by that handler once the offending close has settled.
284290
pcall(function()
285291
if position == "top" then
286292
vim.api.nvim_win_set_config(windows[1], { split = "above", win = -1 })

‎tests/test_integrations.lua‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ for _, case in ipairs({ { name = "above" }, { name = "below" } }) do
215215
end
216216

217217
T["top integration"]["closing a git commit keeps the top and bottom stacks intact"] = function()
218+
-- Regression: creating a commit in fugitive and then closing the gitcommit
219+
-- window used to abort the reposition handlers with `E242: Can't split a
220+
-- window while closing another`, because recreating a side buffer on
221+
-- `WinClosed` re-enters `reposition_stack` mid-close. The close must leave
222+
-- the fugitive (top) and trouble (bottom) stacks intact instead.
218223
child.lua([[
219224
local tmpdir = vim.fn.tempname()
220225
vim.fn.mkdir(tmpdir, "p")

0 commit comments

Comments
 (0)