fix: Neovim closes on bdelete (#333)

This commit is contained in:
Steven Arcangeli 2023-12-24 02:00:57 +00:00
parent ef08437108
commit e2e3bc2df4

View file

@ -95,7 +95,15 @@ M.on_enter_buffer = util.throttle(function()
(not source_win and config.attach_mode ~= "global")
or vim.tbl_count(vim.api.nvim_tabpage_list_wins(0)) == 1
then
vim.cmd("quit")
-- If aerial is the last window open, we must have closed the other windows. If the others
-- were closed via "quit" or similar, we should quit neovim.
local last_cmd = vim.fn.histget("cmd", -1)
local cmd1 = last_cmd:sub(1, 1)
local cmd2 = last_cmd:sub(1, 2)
local cmd3 = last_cmd:sub(1, 3)
if cmd2 == "wq" or cmd1 == "q" or cmd1 == "x" or cmd3 == "exi" then
vim.cmd.quit()
end
end
return
end