Skip to content
Merged
Changes from all commits
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
11 changes: 7 additions & 4 deletions src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ fn color_multilines(color: Colour, s: &str) -> String {

#[derive(Debug)]
pub struct ContextConfig<'a> {
context_size: usize,
skipping_marker: &'a str,
pub context_size: usize,
pub skipping_marker: &'a str,
}

/// Container for line-by-line text diff result. Can be pretty-printed by Display trait.
Expand Down Expand Up @@ -495,10 +495,10 @@ impl<'a> LineChangeset<'a> {

let mut next_line = 1;

let diff = self.diff();
let mut diff = self.diff().into_iter().peekable();
let mut out: Vec<String> = Vec::with_capacity(diff.len());
let mut at_beginning = true;
for op in diff {
while let Some(op) = diff.next() {
match op {
basic::DiffOp::Equal(a) => match context_config {
None => out.push(a.join("\n")),
Expand Down Expand Up @@ -531,6 +531,9 @@ impl<'a> LineChangeset<'a> {
out.push(skipping_marker.to_string());
next_line += lower_bound
}
if diff.peek().is_none() {
continue;
}
if let Some(newlines) = self.format_equal(
&lines[lower_bound..],
display_line_numbers,
Expand Down