Skip to content

Commit

Permalink
fix(signs): hunks can be nil
Browse files Browse the repository at this point in the history
  • Loading branch information
odrling authored and lewis6991 committed Sep 18, 2022
1 parent 231fa92 commit f98c85e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lua/gitsigns/manager.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion teal/gitsigns/manager.tl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ local function apply_win_signs(bufnr: integer, hunks: {Hunk}, top: integer, bot:
signs:remove(bufnr) -- Remove all signs
end

-- hunks can be nil
hunks = hunks or {}

-- To stop the sign column width changing too much, if there are signs to be
-- added but none of them are visible in the window, then make sure to add at
-- least one sign. Only do this on the first call after an update when we all
Expand All @@ -65,7 +68,7 @@ local function apply_win_signs(bufnr: integer, hunks: {Hunk}, top: integer, bot:
signs:add(bufnr, gs_hunks.calc_signs(hunks[1], hunks[1].added.start, hunks[1].added.start))
end

for _, hunk in ipairs(hunks or {}) do
for _, hunk in ipairs(hunks) do
if top <= hunk.vend and bot >= hunk.added.start then
signs:add(bufnr, gs_hunks.calc_signs(hunk, top, bot))
end
Expand Down

0 comments on commit f98c85e

Please sign in to comment.