Skip to content

Commit

Permalink
fix(text): fix substract with overflow panic (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin271 authored Jan 21, 2024
1 parent de8fe05 commit 5bca55d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ impl TextBox {
}
}

/// Returns the [`Text`] in the given [`TextSystem`] with the cursor over it, if any.
pub fn find_hoverable<'a>(
&'a self,
text_system: &mut TextSystem,
Expand All @@ -200,8 +201,7 @@ impl TextBox {
let line = &buffer.lines[cursor.line];
let mut index = cursor.index;
if cursor.affinity == Affinity::Before {
// FIXME (Can we assume that the glyph is 1 index wide)
index -= 1;
index = index.saturating_sub(1);
}
let text = &self.texts[line.attrs_list().get_span(index).metadata];
Some(text)
Expand Down

0 comments on commit 5bca55d

Please sign in to comment.