mirror of https://github.com/zkat/miette.git
use std::cmp::max instead of manual calculation
This commit is contained in:
parent
36f7f65f87
commit
b1e2bd2563
|
|
@ -405,16 +405,12 @@ impl GraphicalReportHandler {
|
||||||
// The snippets will overlap, so we create one Big Chunky Boi
|
// The snippets will overlap, so we create one Big Chunky Boi
|
||||||
let left_end = left.offset() + left.len();
|
let left_end = left.offset() + left.len();
|
||||||
let right_end = right.offset() + right.len();
|
let right_end = right.offset() + right.len();
|
||||||
|
let new_end = std::cmp::max(left_end, right_end);
|
||||||
|
|
||||||
let new_span = LabeledSpan::new(
|
let new_span = LabeledSpan::new(
|
||||||
left.label().map(String::from),
|
left.label().map(String::from),
|
||||||
left.offset(),
|
left.offset(),
|
||||||
if right_end >= left_end {
|
new_end - left.offset(),
|
||||||
// Right end goes past left end
|
|
||||||
right_end - left.offset()
|
|
||||||
} else {
|
|
||||||
// right is contained inside left
|
|
||||||
left.len()
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
// Check that the two contexts can be combined
|
// Check that the two contexts can be combined
|
||||||
if let Ok(new_conts) =
|
if let Ok(new_conts) =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue