hedyhli / outline.nvim

Code outline sidebar powered by LSP. Significantly enhanced & refactored fork of symbols-outline.nvim.
https://sr.ht/~hedy/outline.nvim
MIT License
584 stars 17 forks source link

fix: close the last window #91

Closed mengq627 closed 1 week ago

gennaro-tedesco commented 1 week ago

Good morning! After this recent commit I see an error

09:02:13 msg_show   q Error executing lua callback: ...cal/share/nvim/lazy/outline.nvim/lua/outline/sidebar.lua:389: Cursor position outside buffer
stack traceback:
    [C]: in function 'nvim_win_set_cursor'
    ...cal/share/nvim/lazy/outline.nvim/lua/outline/sidebar.lua:389: in function '__goto_location'
    ...cal/share/nvim/lazy/outline.nvim/lua/outline/sidebar.lua:201: in function <...cal/share/nvim/lazy/outline.nvim/lua/outline/sidebar.lua:198>
   Error  09:02:13 msg_show.lua_error   q Error detected while processing CursorMoved Autocommands for "<buffer=6>":
   Error  09:02:13 msg_show.lua_error   q Error detected while processing CursorMoved Autocommands for "<buffer=6>":
09:02:13 msg_show   q Error executing lua callback: ...cal/share/nvim/lazy/outline.nvim/lua/outline/sidebar.lua:389: Invalid window id: 1000
stack traceback:
    [C]: in function 'nvim_win_set_cursor'
    ...cal/share/nvim/lazy/outline.nvim/lua/outline/sidebar.lua:389: in function '__goto_location'
    ...cal/share/nvim/lazy/outline.nvim/lua/outline/sidebar.lua:201: in function <...cal/share/nvim/lazy/outline.nvim/lua/outline/sidebar.lua:198>

when closing :q a window (generally the main buffer window) while outline is open.

to make this a config option

is this already configurable/have I missed this option to enable/disable such behaviour?

hedyhli commented 1 week ago

Ah, looks like auto_jump is attempting to go to the code buffer location when the code buffer is already closed. I'll look into it.

gennaro-tedesco commented 1 week ago

Thank you for looking into it so quickly!

What is the expected behaviour of this feature, however? I still see the outline window open when the last window is closed (or the buffer deleted).

hedyhli commented 1 week ago

Nope, it doesn't do anything when the code window closes. This PR allows the outline as the last window to be closed (as if with :q) when you press q to close the outline - it previously produced an error.

The use case is when you want to quit neovim with :[w]q, but forgot to use :[w]qa since the outline window is also open (see #86).