From b1e2bd2563d63d2b212f93f411f085c899aa8c27 Mon Sep 17 00:00:00 2001 From: Lucas Holten Date: Thu, 11 Jan 2024 11:34:25 +0100 Subject: [PATCH] use std::cmp::max instead of manual calculation --- src/handlers/graphical.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/handlers/graphical.rs b/src/handlers/graphical.rs index a1d0616..f742af0 100644 --- a/src/handlers/graphical.rs +++ b/src/handlers/graphical.rs @@ -405,16 +405,12 @@ impl GraphicalReportHandler { // The snippets will overlap, so we create one Big Chunky Boi let left_end = left.offset() + left.len(); let right_end = right.offset() + right.len(); + let new_end = std::cmp::max(left_end, right_end); + 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() - }, + new_end - left.offset(), ); // Check that the two contexts can be combined if let Ok(new_conts) =