mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-08 02:35:44 +02:00
fix: attach_mode="global" never allows multiple windows to open (#369)
There was an edge case with "ignored" window types that would cause `:AerialOpen` in an ignored window to potentially open a second aerial win.
This commit is contained in:
parent
83a79f39b7
commit
228fad1139
2 changed files with 15 additions and 11 deletions
|
@ -115,7 +115,16 @@ end
|
|||
---@param winid? integer
|
||||
---@return integer?
|
||||
M.get_aerial_win = function(winid)
|
||||
return M.get_winid_from_var(winid or 0, "aerial_win")
|
||||
local aerial_win = M.get_winid_from_var(winid or 0, "aerial_win")
|
||||
if not aerial_win and config.attach_mode == "global" then
|
||||
for _, tab_win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
|
||||
if M.is_aerial_win(tab_win) then
|
||||
aerial_win = tab_win
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return aerial_win
|
||||
end
|
||||
|
||||
---@param winid? integer
|
||||
|
|
|
@ -230,15 +230,6 @@ M.open_aerial_in_win = function(src_bufnr, src_winid, aer_winid)
|
|||
end
|
||||
end
|
||||
|
||||
---@param bufnr? integer
|
||||
---@return integer|nil
|
||||
local function get_aerial_win_for_buf(bufnr)
|
||||
local aer_bufnr = util.get_aerial_buffer(bufnr)
|
||||
if aer_bufnr then
|
||||
return util.buf_first_win_in_tabpage(aer_bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
---@param opts? {bufnr?: integer, winid?: integer}
|
||||
---@return boolean
|
||||
M.is_open = function(opts)
|
||||
|
@ -248,7 +239,11 @@ M.is_open = function(opts)
|
|||
if opts.winid then
|
||||
return util.get_aerial_win(opts.winid) ~= nil
|
||||
else
|
||||
return get_aerial_win_for_buf(opts.bufnr) ~= nil
|
||||
local aer_bufnr = util.get_aerial_buffer(opts.bufnr)
|
||||
if aer_bufnr then
|
||||
return util.buf_first_win_in_tabpage(aer_bufnr) ~= nil
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue