Skip to content

Commit

Permalink
rendering: avoid unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Sep 4, 2023
1 parent ee630ab commit 1a2d4bf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rendering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ where
if display_range.start >= display_range.end {
if anything_drawn {
let remaining_bytes = state.parser.as_str().len();
let consumed_bytes = self.text.len() - remaining_bytes;

let consumed_bytes = self.text.len().saturating_sub(remaining_bytes);
state.plugin.post_render(
&mut display,
&self.character_style,
Expand All @@ -141,7 +140,8 @@ where
),
)?;
state.plugin.on_rendering_finished();
return Ok(self.text.get(consumed_bytes..).unwrap());

return Ok(&self.text[consumed_bytes..]);
}
} else {
anything_drawn = true;
Expand Down

0 comments on commit 1a2d4bf

Please sign in to comment.