From a69020422e546efbe9256e30d9da10ad67f5ce03 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Thu, 23 Sep 2021 06:56:38 +1200 Subject: [PATCH] fix(graphical): Fix off-by-one span_applies calculation (#70) This changes the span_applies calculation to only count spans where the end of the span is considered part of it if the underline spills into it. I believe this happens if, say, the span.offset() is 10 and span.len() is 2, then we want to count offsets 10 and 11 as part of the span and those would spill, but not 12 as it's the "one past the end" where we know when to stop underlining. --- src/handlers/graphical.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handlers/graphical.rs b/src/handlers/graphical.rs index 2cc40ce..f2965c4 100644 --- a/src/handlers/graphical.rs +++ b/src/handlers/graphical.rs @@ -713,11 +713,11 @@ impl Line { fn span_applies(&self, span: &FancySpan) -> bool { // Span starts in this line - (span.offset() >= self.offset && span.offset() < self.offset +self.length) + (span.offset() >= self.offset && span.offset() < self.offset + self.length) // Span passes through this line || (span.offset() < self.offset && span.offset() + span.len() > self.offset + self.length) //todo // Span ends on this line - || (span.offset() + span.len() >= self.offset && span.offset() + span.len() <= self.offset + self.length) + || (span.offset() + span.len() > self.offset && span.offset() + span.len() <= self.offset + self.length) } // A "flyby" is a multi-line span that technically covers this line, but