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();
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)))
}

View File

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