Skip to content

batches: Fix Diffs render incorrectly

Warren Gifford requested to merge rc/diff-render into main

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

Before

Screen Shot 2022-07-25 at 10 47 06

After

Screen Shot 2022-07-25 at 10 46 34

Merge request reports

Loading