Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(blame): show same commit twice or more #1136

Merged

Conversation

antoinemadec
Copy link
Contributor

@antoinemadec antoinemadec commented Oct 20, 2024

Fixes #1121

issue

  1. show_commit() always creates a new buffer and set its name according to the SHA1
  2. that buffer is never wiped
  3. when calling show_commit() twice on the same commit, we end up trying to create a 2nd buffer with the same name as a preexisting one
Error executing vim.schedule lua callback: ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:95: The async coroutine failed: ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/blame.lua:194: Failed to rename buffer
stack traceback:
        [C]: in function 'nvim_buf_set_name'
        ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/blame.lua:194: in function <...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/blame.lua:188>
stack traceback:
        [C]: in function 'error'
        ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:95: in function 'cb'
        ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:145: in function <...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:144>

fix

  1. if preexisting buffer with right name: reuse it; else: create a new one
  2. wipe the buffer when closing window

how it was tested

  • Gitsigns blame, press s multiple tiems on the same commit
  • check buffer is not present/listed after its window(s) are closed (same behavior as vim-fugitive)

@lewis6991 lewis6991 merged commit ee7634a into lewis6991:main Oct 20, 2024
6 checks passed
@przepompownia
Copy link

@antoinemadec thanks for fixing before I found time for reporting this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

:Gitsigns blame "Show commit" on same commit hash causes error
3 participants