batches: Fix Diffs render incorrectly
Created by: Piszmog
Closes #35492 (closed).
I removed a function at the bottom of a Go file to replicate the rendering issue. What I found was when an empty -
line (not followed by unchanged lines) is removed, this causes the index of highlightedBase
and hunkLines
to be off (hunkLines
is behind by one). This is because highlightedBase
still includes the empty -
line. So each hunkLine
corresponds to the previous highlighted line.
To fix this, I simply increment baseLine
by one if the empty -
line is removed.
Test plan
Added Go test