Skip to content

Commit

Permalink
fix(graphical): fix coalescing adjacent things when they cross bounda…
Browse files Browse the repository at this point in the history
…ries
  • Loading branch information
zkat committed Sep 22, 2021
1 parent 6c64846 commit 18e0ed7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
37 changes: 22 additions & 15 deletions src/handlers/graphical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,21 +242,28 @@ impl GraphicalReportHandler {
let right_end = right.offset() + right.len();
if left_conts.line() + left_conts.line_count() >= right_conts.line() {
// The snippets will overlap, so we create one Big Chunky Boi
Ok((
LabeledSpan::new(
left.label().map(String::from),
left.offset(),
if right_end >= left_end {
// Right end goes past left end
right_end - left.offset()
} else {
// right is contained inside left
left.len()
},
),
// We'll throw this away later
left_conts,
))
let new_span = LabeledSpan::new(
left.label().map(String::from),
left.offset(),
if right_end >= left_end {
// Right end goes past left end
right_end - left.offset()
} else {
// right is contained inside left
left.len()
},
);
if source
.read_span(new_span.inner(), self.context_lines, self.context_lines)
.is_ok()
{
Ok((
new_span, // We'll throw this away later
left_conts,
))
} else {
Err(((left, left_conts), (right, right_conts)))
}
} else {
Err(((left, left_conts), (right, right_conts)))
}
Expand Down
1 change: 0 additions & 1 deletion src/source_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ fn context_info<'a>(
line_count,
))
} else {
// eprintln!("Out of bounds :(");
Err(MietteError::OutOfBounds)
}
}
Expand Down

0 comments on commit 18e0ed7

Please sign in to comment.