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(signs): hunks can be nil #632

Merged
merged 1 commit into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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