Skip to content

Commit

Permalink
fix!: ignore win/buffer behavior prevents opening aerial at all (#204)
Browse files Browse the repository at this point in the history
Previously the ignore behavior was to not trigger open_automatic, and to
not update the aerial window when attach_mode = "global". Unfortunately,
that means that we end up in a weird state and it's difficult to make
the open/close/toggle behavior in ignored buffers consistent _unless_ we
prevent opening aerial altogether. This essentially makes ignored
buffers the same as unsupported, but with the key difference that it
won't trigger any of the close_automatic_events.

As part of this, we're also changing the default to NOT ignore unlisted
buffers. The main reason for this is that help buffers are unlisted by
default, but aerial supports them.
  • Loading branch information
stevearc committed Jan 6, 2023
1 parent a562b9d commit b1e6c7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
10 changes: 2 additions & 8 deletions lua/aerial/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,10 @@ local default_options = {
icons = {},

-- Control which windows and buffers aerial should ignore.
-- If attach_mode is "global", focusing an ignored window/buffer will
-- not cause the aerial window to update.
-- If open_automatic is true, focusing an ignored window/buffer will not
-- cause an aerial window to open.
-- If open_automatic is a function, ignore rules have no effect on aerial
-- window opening behavior; it's entirely handled by the open_automatic
-- function.
-- Aerial will not open when these are focused, and existing aerial windows will not be updated
ignore = {
-- Ignore unlisted buffers. See :help buflisted
unlisted_buffers = true,
unlisted_buffers = false,

-- List of filetypes to ignore.
filetypes = {},
Expand Down
7 changes: 4 additions & 3 deletions lua/aerial/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ M.close = function()
else
-- No aerial buffer for this buffer.
local backend = backends.get(0)
-- If this buffer has no supported symbols backend or no symbols,
-- If this buffer has no supported symbols backend, or no symbols, or is ignored,
-- look for other aerial windows and close the first
if backend == nil or not data.has_symbols(0) then
if backend == nil or not data.has_symbols(0) or util.is_ignored_win() then
for _, winid in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
if vim.api.nvim_win_is_valid(winid) then
local winbuf = vim.api.nvim_win_get_buf(winid)
Expand Down Expand Up @@ -288,7 +288,7 @@ M.open = function(focus, direction, opts)
opts = vim.tbl_extend("keep", opts or {}, {
winid = nil,
})
if util.is_aerial_buffer(0) then
if util.is_aerial_buffer(0) or util.is_ignored_win() then
return
end
local bufnr, aer_bufnr = util.get_buffers()
Expand All @@ -299,6 +299,7 @@ M.open = function(focus, direction, opts)
end
return
end

direction = direction or util.detect_split_direction()
local aer_winid = create_aerial_window(bufnr, aer_bufnr, direction, opts.winid or aerial_win)
local backend = backends.get(0)
Expand Down

0 comments on commit b1e6c7d

Please sign in to comment.