Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lua/zen/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,15 @@ local function setup(options)
desc = "Recreate the side buffers if they are closed.",
})

vim.api.nvim_create_autocmd({ "BufWinEnter", "FileType" }, {
vim.api.nvim_create_autocmd({ "BufWinEnter", "FileType", "WinNew" }, {
pattern = "*",
callback = function(args)
if is_popup_window(vim.api.nvim_get_current_win()) then
return
end
local filetype = vim.bo[args.buf].filetype
local is_integration = is_buff_integration(args.buf)
if args.event == "BufWinEnter" then
if args.event == "BufWinEnter" or args.event == "WinNew" then
if filetype ~= "" and not is_integration and vim.tbl_count(get_vsplits()) >= 2 then
close_side_buffer("left")
close_side_buffer("right")
Expand Down
13 changes: 13 additions & 0 deletions tests/test_splits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ T["vsplit"]["opening closes zen side buffers"] = function()
})
end

T["vsplit"]["splitting the current buffer closes zen side buffers"] = function()
child.cmd("edit test.lua")
child.cmd("vsplit")

Helpers.expect.layout(child, {
type = "row",
children = {
{ type = "leaf", filetype = "lua", buftype = "", width = 120, height = 50 },
{ type = "leaf", filetype = "lua", buftype = "", width = 119, height = 50 },
},
})
end

T["vsplit"]["closing reopens zen side buffers"] = function()
child.cmd("edit test.lua")
child.cmd("vsplit test2.lua")
Expand Down
Loading