From e96693e30da72b495d5172a9f4791b5e85c70695 Mon Sep 17 00:00:00 2001 From: Mika Vilpas Date: Sat, 21 Jun 2025 20:29:40 +0300 Subject: [PATCH] fix: closing lazygit when any neovim `TermClose` event fires **Issue:** After starting lazygit, if you start an unrelated terminal in Neovim and then close it, the lazygit is also closed. This is because the `TermClose` event is currently triggered for all terminal buffers, not just the one running lazygit. I ran into this when using https://github.com/mikavilpas/yazi.nvim, but didn't notice it happens until now. **Solution:** Only close lazygit when the terminal buffer that lazygit is running in is closed. --- lua/tsugit.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/tsugit.lua b/lua/tsugit.lua index 5e6aac0..bf277b8 100644 --- a/lua/tsugit.lua +++ b/lua/tsugit.lua @@ -214,7 +214,9 @@ function M.toggle(args, options) if newLazyGit then newLazyGit:hide() end - end) + end, { + buffer = lazygit.buf, + }) lazygit:on("WinLeave", function() lazygit:hide()