Skip to content

Commit

Permalink
fix(actions.show): check buffer is attached
Browse files Browse the repository at this point in the history
Fixes #865
  • Loading branch information
lewis6991 committed Aug 31, 2023
1 parent d8b52fc commit 44adf80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lua/gitsigns/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1079,8 +1079,13 @@ CP.diffthis = complete_heads
--- Attributes: ~
--- {async}
M.show = function(revision)
local bufnr = api.nvim_get_current_buf()
if not cache[bufnr] then
print('Error: Buffer is not attached.')
return
end
local diffthis = require('gitsigns.diffthis')
diffthis.show(revision)
diffthis.show(bufnr, revision)
end

CP.show = complete_heads
Expand Down
4 changes: 2 additions & 2 deletions lua/gitsigns/diffthis.lua
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ M.diffthis = async.void(function(base, opts)
api.nvim_set_current_win(cwin)
end)

--- @param bufnr integer
--- @param base string
M.show = async.void(function(base)
local bufnr = api.nvim_get_current_buf()
M.show = async.void(function(bufnr, base)
local bufname = create_show_buf(bufnr, base)
if not bufname then
return
Expand Down

0 comments on commit 44adf80

Please sign in to comment.