mirror of https://github.com/zkat/miette.git
fix(graphical): fix coalescing adjacent things when they cross boundaries
This commit is contained in:
parent
6c6484633e
commit
18e0ed7749
|
|
@ -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)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ fn context_info<'a>(
|
|||
line_count,
|
||||
))
|
||||
} else {
|
||||
// eprintln!("Out of bounds :(");
|
||||
Err(MietteError::OutOfBounds)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue