Skip to content

Commit

Permalink
fix(blame): track buffers changes correctly in the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis6991 committed Jun 20, 2024
1 parent bcae839 commit 0349546
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lua/gitsigns/cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ local M = {
--- @field staged_diffs? Gitsigns.Hunk.Hunk[]
--- @field gitdir_watcher? uv.uv_fs_event_t
--- @field git_obj Gitsigns.GitObj
--- @field blame? table<integer,Gitsigns.BlameInfo?>
--- @field blame? table<integer,Gitsigns.BlameInfo|false?>
local CacheEntry = M.CacheEntry

function CacheEntry:get_rev_bufname(rev)
Expand Down
16 changes: 7 additions & 9 deletions lua/gitsigns/manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ local function apply_win_signs(bufnr, top, bot, clear)
end
end

--- @param blame table<integer,Gitsigns.BlameInfo?>?
--- @param blame table<integer,Gitsigns.BlameInfo|false?>?
--- @param first integer
--- @param last_orig integer
--- @param last_new integer
Expand All @@ -88,16 +88,14 @@ local function on_lines_blame(blame, first, last_orig, last_new)
return
end

if last_new ~= last_orig then
if last_new < last_orig then
util.list_remove(blame, last_new, last_orig)
else
util.list_insert(blame, last_orig, last_new)
end
if last_new < last_orig then
util.list_remove(blame, last_new + 1, last_orig)
elseif last_new > last_orig then
util.list_insert(blame, last_orig + 1, last_new, false)
end

for i = math.min(first + 1, last_new), math.max(first + 1, last_new) do
blame[i] = nil
for i = first + 1, last_new do
blame[i] = false
end
end

Expand Down

0 comments on commit 0349546

Please sign in to comment.