mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-12 23:23:20 +00:00
files: ensure that DiffLineIterator hunk has exactly two inputs
I've made the constructor public, so let's add more sanity checks.
This commit is contained in:
parent
95e8dd51eb
commit
ac27365290
1 changed files with 5 additions and 2 deletions
|
@ -103,7 +103,10 @@ where
|
|||
}
|
||||
}
|
||||
DiffHunk::Different(contents) => {
|
||||
let left_lines = contents[0].split_inclusive(|b| *b == b'\n');
|
||||
let [left_text, right_text] = contents[..]
|
||||
.try_into()
|
||||
.expect("hunk should have exactly two inputs");
|
||||
let left_lines = left_text.split_inclusive(|b| *b == b'\n');
|
||||
for left_line in left_lines {
|
||||
self.current_line.has_left_content = true;
|
||||
self.current_line
|
||||
|
@ -115,7 +118,7 @@ where
|
|||
self.current_line.reset_line();
|
||||
}
|
||||
}
|
||||
let right_lines = contents[1].split_inclusive(|b| *b == b'\n');
|
||||
let right_lines = right_text.split_inclusive(|b| *b == b'\n');
|
||||
for right_line in right_lines {
|
||||
self.current_line.has_right_content = true;
|
||||
self.current_line
|
||||
|
|
Loading…
Reference in a new issue