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,8 +242,7 @@ 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 {
|
||||||
|
|
@ -253,13 +252,21 @@ impl GraphicalReportHandler {
|
||||||
// right is contained inside left
|
// right is contained inside left
|
||||||
left.len()
|
left.len()
|
||||||
},
|
},
|
||||||
),
|
);
|
||||||
// We'll throw this away later
|
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,
|
left_conts,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
Err(((left, left_conts), (right, right_conts)))
|
Err(((left, left_conts), (right, right_conts)))
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Err(((left, left_conts), (right, right_conts)))
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
for (ctx, _) in contexts {
|
for (ctx, _) in contexts {
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,6 @@ fn context_info<'a>(
|
||||||
line_count,
|
line_count,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
// eprintln!("Out of bounds :(");
|
|
||||||
Err(MietteError::OutOfBounds)
|
Err(MietteError::OutOfBounds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue