fix(graphical): fix coalescing adjacent things when they cross boundaries

This commit is contained in:
Kat Marchán 2021-09-21 17:50:42 -07:00
parent 6c6484633e
commit 18e0ed7749
2 changed files with 22 additions and 16 deletions

View File

@ -242,21 +242,28 @@ impl GraphicalReportHandler {
let right_end = right.offset() + right.len(); let right_end = right.offset() + right.len();
if left_conts.line() + left_conts.line_count() >= right_conts.line() { if left_conts.line() + left_conts.line_count() >= right_conts.line() {
// The snippets will overlap, so we create one Big Chunky Boi // The snippets will overlap, so we create one Big Chunky Boi
Ok(( let new_span = LabeledSpan::new(
LabeledSpan::new( left.label().map(String::from),
left.label().map(String::from), left.offset(),
left.offset(), if right_end >= left_end {
if right_end >= left_end { // Right end goes past left end
// Right end goes past left end right_end - left.offset()
right_end - left.offset() } else {
} else { // right is contained inside left
// right is contained inside left left.len()
left.len() },
}, );
), if source
// We'll throw this away later .read_span(new_span.inner(), self.context_lines, self.context_lines)
left_conts, .is_ok()
)) {
Ok((
new_span, // We'll throw this away later
left_conts,
))
} else {
Err(((left, left_conts), (right, right_conts)))
}
} else { } else {
Err(((left, left_conts), (right, right_conts))) Err(((left, left_conts), (right, right_conts)))
} }

View File

@ -92,7 +92,6 @@ fn context_info<'a>(
line_count, line_count,
)) ))
} else { } else {
// eprintln!("Out of bounds :(");
Err(MietteError::OutOfBounds) Err(MietteError::OutOfBounds)
} }
} }