Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/compute-lines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,14 @@ const computeLineInformation = (
right.value = line;
}

counter += 1;

// `counter` tracks the index of the line inside `lineInformation`, which
// is what `diffLines` records. The lookahead pass (`isRetrieveNext`) only
// borrows the right side of an already-counted modification line, so it
// must not advance the counter - otherwise `diffLines` drifts ahead of
// the real line indexes by one for every modification, which pushes the
// "Expand x lines ..." indicator below the diff block it belongs to.
if (!isRetrieveNext) {
counter += 1;
lineInformation.push({
left,
right,
Expand Down
8 changes: 4 additions & 4 deletions test/compute-lines.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ Also this info`;
left: {},
},
],
diffLines: [0, 2],
diffLines: [0, 1],
});
});

Expand Down Expand Up @@ -304,7 +304,7 @@ Also this info`;
left: {},
},
],
diffLines: [0, 2],
diffLines: [0, 1],
});
});

Expand Down Expand Up @@ -336,7 +336,7 @@ Also this info`;
left: {},
},
],
diffLines: [0, 2],
diffLines: [0, 1],
});
});

Expand Down Expand Up @@ -370,7 +370,7 @@ Also this info`;
left: {},
},
],
diffLines: [0, 2],
diffLines: [0, 1],
});
});
});
Loading