From 8581c43f19367106d6cdad034dc314d45e63bf29 Mon Sep 17 00:00:00 2001 From: arichi Date: Sun, 7 Dec 2025 02:54:24 +0100 Subject: [PATCH] Commit info popup issues 1. Close the commit info popup if full commit view is entered, otherwise it remains on the screen with no way to close it. 2. Check that the saved window is valid before attempting to reuse it. This triggering an error if the blame window got closed by pressing escape while commit info popup is shown. 3. Delay augroup delete so that the popup is correctly closed when the main window is closed (solution by leiswatch) --- lua/blame/commit_info.lua | 2 +- lua/blame/views/window_view.lua | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/blame/commit_info.lua b/lua/blame/commit_info.lua index e437e7c..74ed417 100644 --- a/lua/blame/commit_info.lua +++ b/lua/blame/commit_info.lua @@ -25,7 +25,7 @@ function CommitInfo:close(cleanup) then vim.api.nvim_win_close(self.commit_info_window, true) end - if self.saved_win and self.saved_pos then + if self.saved_win and self.saved_pos and vim.api.nvim_win_is_valid(self.saved_win) then vim.api.nvim_set_current_win(self.saved_win) vim.api.nvim_win_set_cursor(self.saved_win, self.saved_pos) end diff --git a/lua/blame/views/window_view.lua b/lua/blame/views/window_view.lua index 5f64172..af632f3 100644 --- a/lua/blame/views/window_view.lua +++ b/lua/blame/views/window_view.lua @@ -235,7 +235,6 @@ end function WindowView:close(cleanup) if self.blame_window ~= nil then - vim.api.nvim_del_augroup_by_name("NvimBlame") self.blame_stack_client:close() --if original window still present *Reset options* @@ -256,6 +255,8 @@ function WindowView:close(cleanup) "User", { pattern = "BlameViewClosed", modeline = false, data = "window" } ) + + vim.api.nvim_del_augroup_by_name("NvimBlame") self.original_window = nil self.blame_window = nil self.blamed_lines = nil @@ -342,6 +343,9 @@ function WindowView:show_full_commit() local row, _ = unpack(vim.api.nvim_win_get_cursor(self.blame_window)) local commit = self.blamed_lines[row] local view = self.config.commit_detail_view or "tab" + if self.commit_info:is_open() == true then + self.commit_info:close(false) + end if type(view) == 'function' then local path = self.blame_stack_client.file_path view(commit.hash, row, path)