Skip to content

Commit 76b047c

Browse files
committed
Use LineRange::with_offset
1 parent b953eaa commit 76b047c

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

gix-blame/tests/blame.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -456,25 +456,26 @@ fn process_change(
456456
(new_hunk, None)
457457
}
458458
(true, false) => {
459-
*offset_in_destination += added.end - added.start;
460-
*offset_in_destination -= number_of_lines_deleted;
461-
462459
// <--------> (hunk)
463460
// <-------> (added)
464461
// <----> (blamed)
465462
// <--> (new hunk)
466-
if added.start > hunk.range_in_destination.start {
467-
let Offset::Added(added_in_destination) = offset_in_destination else {
468-
todo!()
469-
};
470463

471-
new_hunks_to_blame.push(UnblamedHunk::new(
472-
(hunk.range_in_destination.start + *added_in_destination)
473-
..(added.start + *added_in_destination),
464+
if added.start > hunk.range_in_destination.start {
465+
let line_range_in_next_destination = LineRange::with_offset(
466+
hunk.range_in_destination.start..added.start,
474467
*offset_in_destination,
468+
);
469+
470+
new_hunks_to_blame.push(UnblamedHunk::from_destination(
471+
line_range_in_next_destination.into(),
472+
hunk.offset() + *offset_in_destination,
475473
));
476474
}
477475

476+
*offset_in_destination += added.end - added.start;
477+
*offset_in_destination -= number_of_lines_deleted;
478+
478479
lines_blamed.push(BlameEntry::with_offset(
479480
added.start..hunk.range_in_destination.end,
480481
suspect,

0 commit comments

Comments
 (0)