Skip to content

Commit

Permalink
feat: set bufname for commit buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis6991 committed Jun 21, 2024
1 parent 93c38d9 commit e4efe9b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lua/gitsigns/blame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ local show_commit = async.create(3, function(win, open, bcache)
local sha = bcache.blame[cursor].commit.sha
local res = bcache.git_obj:command({ 'show', sha })
async.scheduler()
local commit_buf = api.nvim_create_buf(false, true)
local commit_buf = api.nvim_create_buf(true, true)
api.nvim_buf_set_name(commit_buf, bcache:get_rev_bufname(sha, true))
api.nvim_buf_set_lines(commit_buf, 0, -1, false, res)
vim.cmd[open]({ mods = { keepalt = true } })
api.nvim_win_set_buf(0, commit_buf)
Expand Down Expand Up @@ -273,6 +274,7 @@ M.blame = function()

local blm_bo = vim.bo[blm_bufnr]
blm_bo.buftype = 'nofile'
blm_bo.bufhidden = 'wipe'
blm_bo.modifiable = false
blm_bo.filetype = 'gitsigns.blame'

Expand Down
5 changes: 4 additions & 1 deletion lua/gitsigns/cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ local M = {
--- @field blame? table<integer,Gitsigns.BlameInfo?>
local CacheEntry = M.CacheEntry

function CacheEntry:get_rev_bufname(rev)
function CacheEntry:get_rev_bufname(rev, nofile)
rev = rev or self.git_obj.revision or ':0'
if nofile then
return string.format('gitsigns://%s/%s', self.git_obj.repo.gitdir, rev)
end
return string.format('gitsigns://%s/%s:%s', self.git_obj.repo.gitdir, rev, self.git_obj.relpath)
end

Expand Down

0 comments on commit e4efe9b

Please sign in to comment.