mirror of
https://github.com/lewis6991/gitsigns.nvim
synced 2025-02-15 19:56:52 +00:00
fix(blame): ensure blame object is valid when all lines are requested
Some checks failed
CI / commit_lint (push) Has been cancelled
CI / test (nightly) (push) Has been cancelled
CI / test (v0.10.0) (push) Has been cancelled
CI / test (v0.9.5) (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / doc (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / luarocks-upload (push) Has been cancelled
release-please / update-doc (push) Has been cancelled
Some checks failed
CI / commit_lint (push) Has been cancelled
CI / test (nightly) (push) Has been cancelled
CI / test (v0.10.0) (push) Has been cancelled
CI / test (v0.9.5) (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / doc (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / luarocks-upload (push) Has been cancelled
release-please / update-doc (push) Has been cancelled
Fixes #1156
This commit is contained in:
parent
0797734e2b
commit
817bd848ff
@ -267,7 +267,7 @@ local function menu(name, items)
|
||||
end
|
||||
|
||||
--- @async
|
||||
M.blame = function()
|
||||
function M.blame()
|
||||
local __FUNC__ = 'blame'
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
local win = api.nvim_get_current_win()
|
||||
|
@ -101,6 +101,29 @@ function CacheEntry:run_blame(lnum, opts)
|
||||
return blame, lnum0 == nil
|
||||
end
|
||||
|
||||
--- @private
|
||||
--- @param lnum? integer
|
||||
--- @return boolean
|
||||
function CacheEntry:blame_valid(lnum)
|
||||
local blame = self.blame
|
||||
if not blame then
|
||||
return false
|
||||
end
|
||||
|
||||
if lnum then
|
||||
return blame[lnum] ~= nil
|
||||
end
|
||||
|
||||
-- Need to check we have blame info for all lines
|
||||
for i = 1, vim.api.nvim_buf_line_count(self.bufnr) do
|
||||
if not blame[i] then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--- If lnum is nil then run blame for the entire buffer.
|
||||
--- @async
|
||||
--- @param lnum? integer
|
||||
@ -109,7 +132,7 @@ end
|
||||
function CacheEntry:get_blame(lnum, opts)
|
||||
local blame = self.blame
|
||||
|
||||
if not blame or (lnum and not blame[lnum]) then
|
||||
if not blame or not self:blame_valid(lnum) then
|
||||
self:wait_for_hunks()
|
||||
blame = blame or {}
|
||||
local Hunks = require('gitsigns.hunks')
|
||||
|
Loading…
Reference in New Issue
Block a user