Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the HunkCoalescer again #214

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -240,6 +240,9 @@ private Context createContextBeforeGroup(Header header, Hunk first) {
private Context createContextAfterHunk(Hunk hunk, Hunk nextNonEmptySourceHunk, Hunk nextNonEmptyTargetHunk) {
var sourceAfterContextStart = hunk.source().range().end();
var sourceAfterContextEnd = hunk.source().range().end() + numContextLines;
if (nextNonEmptySourceHunk != null || nextNonEmptyTargetHunk != null) {
sourceAfterContextEnd += numContextLines; // include the "before" context for the next hunk
}
sourceAfterContextEnd = Math.min(sourceAfterContextEnd, sourceContent.size() + 1);
if (nextNonEmptySourceHunk != null) {
var nextNonEmptySourceHunkStart = nextNonEmptySourceHunk.source().range().start();
@@ -251,19 +254,16 @@ private Context createContextAfterHunk(Hunk hunk, Hunk nextNonEmptySourceHunk, H

var destAfterContextStart = hunk.target().range().end();
var destAfterContextEnd = hunk.target().range().end() + numContextLines;
if (nextNonEmptySourceHunk != null || nextNonEmptyTargetHunk != null) {
destAfterContextEnd += numContextLines; // include the "before" context for the next hunk
}
destAfterContextEnd = Math.min(destAfterContextEnd, destContent.size() + 1);
if (nextNonEmptyTargetHunk != null) {
var nextNonEmptyTargetHunkStart = nextNonEmptyTargetHunk.target().range().start();
destAfterContextEnd = destAfterContextEnd > nextNonEmptyTargetHunkStart
? Math.min(destAfterContextEnd, nextNonEmptyTargetHunkStart)
: Math.max(destAfterContextEnd, nextNonEmptyTargetHunkStart);
}

if (nextNonEmptySourceHunk != null || nextNonEmptyTargetHunk != null) {
sourceAfterContextEnd += numContextLines;
destAfterContextEnd += numContextLines;
}

var destAfterContextCount = destAfterContextEnd - destAfterContextStart;

var afterContextCount = Math.min(sourceAfterContextCount, destAfterContextCount);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.