Skip to content

Commit

Permalink
Account for change hunks with additions. #129
Browse files Browse the repository at this point in the history
  • Loading branch information
dstein64 committed Mar 20, 2024
1 parent 261e10a commit 5a7eb7e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lua/scrollview/contrib/gitsigns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,29 @@ function M.setup(config)
end
end
elseif hunk.type == 'change' then
-- WARN: A change hunk can be comprised of a change (the removed
-- lines) and an add (lines added after the removed lines). #129
local first = hunk.added.start
local last = hunk.added.start
local last = first
if not config.only_first_line then
last = last + hunk.added.count - 1
if hunk.added.count > hunk.removed.count then
last = last - (hunk.added.count - hunk.removed.count)
end
end
for line = first, last do
table.insert(lines_change, line)
end
if hunk.added.count > hunk.removed.count then
first = hunk.added.start + hunk.removed.count
last = first
if not config.only_first_line then
last = last + hunk.added.count - hunk.removed.count - 1
end
for line = first, last do
table.insert(lines_add, line)
end
end
elseif hunk.type == 'delete' then
table.insert(lines_delete, hunk.added.start)
end
Expand Down

0 comments on commit 5a7eb7e

Please sign in to comment.