From d54a663974ecc9b1805fc95f593b1109c8e293c9 Mon Sep 17 00:00:00 2001 From: psychhim Date: Tue, 14 Oct 2025 13:35:21 +0530 Subject: [PATCH] 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. --- lua/keymaps.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/keymaps.lua b/lua/keymaps.lua index aec49b5..78744c9 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -273,7 +273,7 @@ local function close_window(mode) end end -- 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 buffer had unsaved changes and user chose to discard, force quit vim.cmd 'qa!' @@ -284,8 +284,10 @@ local function close_window(mode) end -- Close logic if win_count > 1 then + -- Buffer is visible in other windows/tabs: just close current window vim.cmd 'close' else + -- Buffer is only open in this window: delete the entire buffer from memory if modified and mode ~= 'save' then vim.cmd 'bwipeout!' -- discard changes else