stevearc / aerial.nvim

Neovim plugin for a code outline window
MIT License
1.72k stars 83 forks source link

Automatically close the aerial window when the corresponding buffer is closed #90

Closed krishnakumarg1984 closed 2 years ago

krishnakumarg1984 commented 2 years ago

Description Let's say we open a buffer with some symbols and use aerial to open the symbol tree. When we close the original buffer (e.g. through :bwipeout, :bdelete, <C-W> + c etc, the aerial window should also close. For instance, it is expected that the aerial window shall auto-close when the last valid file/buffer is closed, and can be mildly surprising when just the aerial window persists as the last open buffer.

Currently, the aerial window is left orphaned, pointing to dangling symbols which lead to a bunch of error lines when trying to open.

E5108: Error executing lua ...te/pack/packer/opt/aerial.nvim/lua/aerial/navigation.lua:175: Could not find destination window
stack traceback:
    [C]: in function 'error'
    ...te/pack/packer/opt/aerial.nvim/lua/aerial/navigation.lua:175: in function 'select'
    ...vim/site/pack/packer/opt/aerial.nvim/lua/aerial/init.lua:92: in function 'select'
    [string ":lua"]:1: in main chunk

System information

To Reproduce Steps to reproduce the behavior:

  1. Open any file with suitable symbols (functions, classes etc). e.g. a Lua config file for neovim
  2. Toggle the symbols outline window with :AerialToggle<CR>
  3. Close the original file with :q (or ZZ, ZQ etc). The aerial window alone will persist.

Screenshots image

After :q, we are left with image

And pressing <CR> on any of the symbols in the tree results in an error: image

stevearc commented 2 years ago

This is something that used to work, but must have regressed at some point. Should be fixed now

krishnakumarg1984 commented 2 years ago

Thank you. Indeed it works now. For robustness, is it worth adding a regression test for this issue?

stevearc commented 2 years ago

It would be nice to have, but would take some time and I have other tasks (in general, but also on aerial) that I think are higher priority

ronandalton commented 2 months ago

Did this stop working again? I'm having the same issue on Neovim 1.10.0. :q seems to work but ctrl-w q and ZQ/ZZ don't.