Skip to content

Commit

Permalink
fix: ensure floating popup windows are auto closed when they lose focus
Browse files Browse the repository at this point in the history
Fixes #591
  • Loading branch information
PriceHiller committed Jul 14, 2023
1 parent 36ffabb commit e3305a2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lua/neogit/lib/popup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,19 @@ function M:show()
}
end,
}

-- Closes the window if it loses focus and it is a floating buffer
if self.buffer.kind == "floating" then
vim.api.nvim_create_autocmd("WinLeave", {
callback = function(win)
if win.buf == self.buffer.handle then
-- We pcall this because it's possible the window was closed by a command invocation, e.g. "cc" for commits
pcall(self.close)
end
end,
once = true
})
end
end

return M

0 comments on commit e3305a2

Please sign in to comment.