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 1d80f72 commit 46021d6
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lua/scrollview/contrib/gitsigns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,26 @@ function M.setup(config)
end
end
elseif hunk.type == 'change' then
local first = hunk.added.start
local last = hunk.added.start
-- 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.removed.start
local last = first
if not config.only_first_line then
last = last + hunk.added.count - 1
last = last + hunk.removed.count - 1
end
for line = first, last do
table.insert(lines_change, line)
end
if hunk.added.count > hunk.removed.count then
first = hunk.removed.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 46021d6

Please sign in to comment.