Allow to omit large common parts in diff output #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By default disabled, can be enabled and configured with

--context NUM
.Wdyt?
This is my first time writing Go code, please let me know if my naming is off, something should be refactored or just be done differently!
The code iterates over all diff records and keep track of how many lines are between the closest change (addition or removal) before the current line. Then it iterates again through all diff records but backwards and adjusts the distance if the closest change after the current line is closer.
When printing the diff we can then simply omit records that have a distance larger than the desired context.
I have an alternative implementation which first creates chunks and then iterates over chunks of diffs to print, if you prefer it: diff-with-chunks.go.