Fix: If there was a single tab and a single file was open in split modes, closing a single window closed the entire buffer, so all the windows and neovim closed.

This commit is contained in:
psychhim
2025-10-14 13:35:21 +05:30
parent 69578347f1
commit d54a663974

View File

@@ -273,7 +273,7 @@ local function close_window(mode)
end end
end end
-- Special case: last listed buffer in last window -- Special case: last listed buffer in last window
if total_listed == 1 then if total_listed == 1 and win_count == 1 then
if modified and mode ~= 'save' then if modified and mode ~= 'save' then
-- if buffer had unsaved changes and user chose to discard, force quit -- if buffer had unsaved changes and user chose to discard, force quit
vim.cmd 'qa!' vim.cmd 'qa!'
@@ -284,8 +284,10 @@ local function close_window(mode)
end end
-- Close logic -- Close logic
if win_count > 1 then if win_count > 1 then
-- Buffer is visible in other windows/tabs: just close current window
vim.cmd 'close' vim.cmd 'close'
else else
-- Buffer is only open in this window: delete the entire buffer from memory
if modified and mode ~= 'save' then if modified and mode ~= 'save' then
vim.cmd 'bwipeout!' -- discard changes vim.cmd 'bwipeout!' -- discard changes
else else