Skip to content

Commit

Permalink
fix(graphical): Fix off-by-one span_applies calculation (#70)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sophiajt authored and zkat committed Sep 22, 2021
1 parent 8d1170e commit a690204
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/handlers/graphical.rs
Expand Up @@ -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
Expand Down

0 comments on commit a690204

Please sign in to comment.