Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: :bdelete will crash or close nvim when an inactive Aerial buffer is open #333

Closed
ienapliss opened this issue Dec 8, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@ienapliss
Copy link

ienapliss commented Dec 8, 2023

Neovim version (nvim -v)

v0.9.4

Operating system/version

Windows 11, mingw-64 neovim

Output of :AerialInfo

Filetype: cpp
lsp: attached
treesitter: supported

Describe the bug

If an Aerial buffer is present while working from another buffer, calling :bdelete will crash or quit nvim instead of just closing the buffer.

If I call :bdelete from inside the Aerial buffer, it close Aerial as expected.

But if I return on my other buffer and call :bdelete from there (Aerial buffer inactive) either nvim will crash or simply quit (hard to tell) instead of closing the buffer and remain open as expected.

If I toggle Aerial off with the same ":AerialToggle! left" then I can :bdelete the buffer as expected. So this bug happen when Aerial is open but in an inactive buffer. Also, when I open another unrelated buffer, I can still close the buffer without problem. Only the buffer in which I toggle Aerial from is affected.

Right now the only workaround is to append :AerialCloseAll before calling :bdelete.

Important Update: apparently the bug is not always triggered when a single buffer is opened. But opening two or more buffers seems to always reproduce it 100% of the time.

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

Open more than 1 files.
Open Aerial with ":AerialToggle! left"
Change to another buffer (not Aerial).
Call ":bdelete".

Expected Behavior

:bdelete command should simply close the buffer. But it will crash or quit nvim instead.

Minimal example file

No response

Minimal init.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "stevearc/aerial.nvim",
    config = function()
      require("aerial").setup({
        -- add your aerial config here
      })
    end,
  },
  {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    config = function()
      require("nvim-treesitter.configs").setup({
        ensure_installed = { "c", "lua" },
        auto_install = true,
        highlight = { enable = true },
      })
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Additional context

This bug was previously reported but it was closed without any resolution: "#284"

@ienapliss ienapliss added the bug Something isn't working label Dec 8, 2023
stevearc added a commit that referenced this issue Dec 24, 2023
@stevearc
Copy link
Owner

This is due to an autocmd in aerial that quits when it is the last window open. The intent was that if someone opens a file, then opens aerial, then :quit, we want to exit Neovim instead of closing the main buffer window and leaving up a full-screen empty aerial window.

The reason for the behavior you're seeing is that :bdelete behaves in two different ways. If you call :bdelete with only one listed buffer, it will delete the buffer and open a new empty buffer in the current window (thus, no issues). However, if you have multiple listed buffers and run :bdelete, it deletes the buffer and closes the window. This was triggering the aerial "quit" logic.

I've updated the autocmd to try to only manually quit Neovim if the previous command issued was one that would exit Neovim.

toantk238 added a commit to toantk238/aerial.nvim that referenced this issue Jan 2, 2024
fix: Neovim closes on bdelete (stevearc#333)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants