mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-07 18:34:50 +02:00
fix: do not open_automatic in unsupported buffers (#185)
This commit is contained in:
parent
38c6fe1c19
commit
047e19de04
5 changed files with 31 additions and 3 deletions
|
@ -225,6 +225,9 @@ end
|
|||
---@return boolean
|
||||
M.is_ignored_buf = function(bufnr)
|
||||
bufnr = bufnr or 0
|
||||
if not vim.api.nvim_buf_is_valid(bufnr) then
|
||||
return true
|
||||
end
|
||||
local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype")
|
||||
-- Never ignore aerial buffers
|
||||
if filetype == "aerial" then
|
||||
|
|
|
@ -269,7 +269,8 @@ end
|
|||
---@param bufnr? integer
|
||||
---@return boolean
|
||||
M.maybe_open_automatic = function(bufnr)
|
||||
if config.open_automatic(bufnr or 0) then
|
||||
bufnr = bufnr or 0
|
||||
if config.open_automatic(bufnr) and backends.get(bufnr) then
|
||||
M.open(false)
|
||||
return true
|
||||
else
|
||||
|
|
|
@ -239,4 +239,28 @@ a.describe("config attach_mode = 'global'", function()
|
|||
assert.falsy(vim.api.nvim_win_is_valid(aerial_win))
|
||||
end
|
||||
)
|
||||
|
||||
a.it("open_automatic = true opens aerial when entering supported buffer", function()
|
||||
aerial.setup({
|
||||
lazy_load = false,
|
||||
attach_mode = "global",
|
||||
open_automatic = true,
|
||||
})
|
||||
vim.cmd.edit({ args = { "README.md" } })
|
||||
sleep(30)
|
||||
local aerial_win = util.get_aerial_win(0)
|
||||
assert.truthy(vim.api.nvim_win_is_valid(aerial_win))
|
||||
end)
|
||||
|
||||
a.it("open_automatic = true does not open aerial when entering unsupported buffer", function()
|
||||
aerial.setup({
|
||||
lazy_load = false,
|
||||
attach_mode = "global",
|
||||
open_automatic = true,
|
||||
})
|
||||
vim.cmd.edit({ args = { "LICENSE" } })
|
||||
sleep(30)
|
||||
local aerial_win = util.get_aerial_win(0)
|
||||
assert.is_nil(aerial_win)
|
||||
end)
|
||||
end)
|
||||
|
|
|
@ -2,7 +2,7 @@ require("plenary.async").tests.add_to_env()
|
|||
local aerial = require("aerial")
|
||||
local test_util = require("tests.test_util")
|
||||
|
||||
a.describe("config", function()
|
||||
a.describe("layout", function()
|
||||
after_each(function()
|
||||
test_util.reset_editor()
|
||||
end)
|
||||
|
|
|
@ -2,7 +2,7 @@ local config = require("aerial.config")
|
|||
local data = require("aerial.data")
|
||||
local window = require("aerial.window")
|
||||
|
||||
describe("config", function()
|
||||
describe("symbol positions", function()
|
||||
before_each(function()
|
||||
config.setup()
|
||||
end)
|
||||
|
|
Loading…
Reference in a new issue