Skip to content

Commit

Permalink
fix: Quit when only floating windows exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Isrothy committed Dec 8, 2024
1 parent 093e0ad commit 11ec72a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lua/neominimap/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ M.get_attached_window = function(bufnr)
return attachec_windod
end

M.is_floating = function(winid)
return api.nvim_win_get_config(winid).relative ~= ""
end

--- @param f fun(bufnr: integer)
M.for_all_buffers = function(f)
local buffer_list = api.nvim_list_bufs()
Expand Down
12 changes: 9 additions & 3 deletions lua/neominimap/window/split/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,15 @@ M.refresh_current_tab = function()
local tabid = api.nvim_get_current_tabpage()

if config.split.close_if_last_window then
logger.log("Checking if tab has no window", vim.log.levels.TRACE)
local win_count = #api.nvim_tabpage_list_wins(tabid)
if win_count == 0 or (win_count == 1 and window_map.get_minimap_winid(tabid) ~= nil) then
logger.log("Checking if tab has window", vim.log.levels.TRACE)
local win_list = api.nvim_tabpage_list_wins(tabid)
local none_floating_count = 0
for _, winid in pairs(win_list) do
if not require("neominimap.util").is_floating(winid) then
none_floating_count = none_floating_count + 1
end
end
if none_floating_count == 0 or (none_floating_count == 1 and window_map.get_minimap_winid(tabid) ~= nil) then
logger.log("Tab has no window", vim.log.levels.TRACE)
vim.cmd("noau quit")
return
Expand Down

0 comments on commit 11ec72a

Please sign in to comment.