Skip to content

Commit 8581c43

Browse files
committed
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)
1 parent f3f6153 commit 8581c43

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lua/blame/commit_info.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function CommitInfo:close(cleanup)
2525
then
2626
vim.api.nvim_win_close(self.commit_info_window, true)
2727
end
28-
if self.saved_win and self.saved_pos then
28+
if self.saved_win and self.saved_pos and vim.api.nvim_win_is_valid(self.saved_win) then
2929
vim.api.nvim_set_current_win(self.saved_win)
3030
vim.api.nvim_win_set_cursor(self.saved_win, self.saved_pos)
3131
end

lua/blame/views/window_view.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ end
235235

236236
function WindowView:close(cleanup)
237237
if self.blame_window ~= nil then
238-
vim.api.nvim_del_augroup_by_name("NvimBlame")
239238
self.blame_stack_client:close()
240239

241240
--if original window still present *Reset options*
@@ -256,6 +255,8 @@ function WindowView:close(cleanup)
256255
"User",
257256
{ pattern = "BlameViewClosed", modeline = false, data = "window" }
258257
)
258+
259+
vim.api.nvim_del_augroup_by_name("NvimBlame")
259260
self.original_window = nil
260261
self.blame_window = nil
261262
self.blamed_lines = nil
@@ -342,6 +343,9 @@ function WindowView:show_full_commit()
342343
local row, _ = unpack(vim.api.nvim_win_get_cursor(self.blame_window))
343344
local commit = self.blamed_lines[row]
344345
local view = self.config.commit_detail_view or "tab"
346+
if self.commit_info:is_open() == true then
347+
self.commit_info:close(false)
348+
end
345349
if type(view) == 'function' then
346350
local path = self.blame_stack_client.file_path
347351
view(commit.hash, row, path)

0 commit comments

Comments
 (0)