Skip to content

Conversation

@KineiChou
Copy link

When the exit_when_last option is set to true, closing the last main window should automatically trigger :qa to quit Neovim.

However, this feature is not currently working as expected. When the last main window is closed, Neovim does not exit; instead, the edgy sidebar windows remain.

The WinClosed event fires during the window closing process, not after the window has been completely removed from the window list.

Therefore, when check_main() callback executes, the window being closed still technically exists in Neovim's window list. This causes vim.tbl_isempty(wins.main) to return false, and the :qa exit logic is skipped.

Wrapping the check_main function call in vim.schedule() defers its execution to the 'next tick' of the Neovim event loop, by which point the WinClosed event has fully completed and the window has been removed from the list.

@github-actions github-actions bot added the size/s Small PR (<10 lines changed) label Nov 1, 2025
@KineiChou KineiChou changed the title Fix 'exit_when_last' not working due to autocmd timing issue fix(exit_when_last): 'exit_when_last' not working due to autocmd timing issue Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s Small PR (<10 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant