atom/git-diff

Modified vs Added lines

Closed this issue · 2 comments

I'm not sure if this is intended behavior or not, but it isn't what I was expecting so I thought I'd post an issue. Apologies if this is a non-issue!

When I take code such as:

def dummy_method
end

And change it to:

def dummy_method(num)
  num.times do |i|
    puts "#{i} dummy"
  end
end

Instead of identifying one modified line and three new lines, the gutter indicates I have four modified lines.

If I instead change the code to:

def dummy_method
  10.times do |i|
    puts "#{i} dummy"
  end
end

The gutter displays three new lines. It appears modifying the function definition in this case triggers the difference.

I'm using the Icons setting at the moment.

We use libgit2 to generate the diffs and it reports hunks. The edit in your first example reports a a single hunk where old_lines would be 1 and new_lines would be 3 or 4.

It lacks the information and granularity to detect a single line edit that also has lines added directly after it. It groups them all in a single edit hunk since it was one contiguous region of edits.

I'm not sure this is something we will be able to fix in Atom without implementing some other diff logic on top of what libgit2 provides.

Gotcha, thanks! Probably not worth it in the scheme of things then 😄