feat(#2826): add feature gate experimental.close_other_windows_in_tab
This commit is contained in:
parent
f322a2092a
commit
f7bd7319d2
@ -107,7 +107,6 @@ end
|
|||||||
---@private
|
---@private
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
function View:create_autocmds(bufnr)
|
function View:create_autocmds(bufnr)
|
||||||
-- clear bufnr and winid
|
|
||||||
-- eject buffer opened in the nvim-tree window and create a new buffer
|
-- eject buffer opened in the nvim-tree window and create a new buffer
|
||||||
vim.api.nvim_create_autocmd("BufWipeout", {
|
vim.api.nvim_create_autocmd("BufWipeout", {
|
||||||
group = self.explorer.augroup_id,
|
group = self.explorer.augroup_id,
|
||||||
@ -128,7 +127,6 @@ function View:create_autocmds(bufnr)
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- close any other windows containing this buffer
|
|
||||||
-- not fired when entering the first window, only subsequent event such as following a split
|
-- not fired when entering the first window, only subsequent event such as following a split
|
||||||
-- does fire on :tabnew for _any_ buffer
|
-- does fire on :tabnew for _any_ buffer
|
||||||
vim.api.nvim_create_autocmd("WinEnter", {
|
vim.api.nvim_create_autocmd("WinEnter", {
|
||||||
@ -149,6 +147,20 @@ function View:create_autocmds(bufnr)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- close other windows in this tab
|
||||||
|
self:close_other_windows(bufnr)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
---Close any other windows containing this buffer and setup current window
|
||||||
|
---Feature gated behind experimental.close_other_windows_in_tab
|
||||||
|
---@param bufnr integer
|
||||||
|
function View:close_other_windows(bufnr)
|
||||||
|
if not self.explorer.opts.experimental.close_other_windows_in_tab then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- are there any other windows containing bufnr?
|
-- are there any other windows containing bufnr?
|
||||||
local winids_buf = vim.fn.win_findbuf(bufnr)
|
local winids_buf = vim.fn.win_findbuf(bufnr)
|
||||||
if #winids_buf <= 1 then
|
if #winids_buf <= 1 then
|
||||||
@ -163,11 +175,9 @@ function View:create_autocmds(bufnr)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- setup this window, it may be new e.g. split
|
-- setup current window, it may be new e.g. split
|
||||||
self:set_window_options_and_buffer()
|
self:set_window_options_and_buffer()
|
||||||
self:resize()
|
self:resize()
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO multi-instance remove this; delete buffers rather than retaining them
|
-- TODO multi-instance remove this; delete buffers rather than retaining them
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user