summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-17 19:06:20 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-17 19:06:20 +0200
commit23d00445ff1225b3e5ca99cb27966143cda8a2ce (patch)
tree1a252b0e78ec381a0e0bd2c37732c7a11bf6b51b /graphics
parentd3011992a76e83e12f74402c2ade616cdc7f1497 (diff)
downloadiced-23d00445ff1225b3e5ca99cb27966143cda8a2ce.tar.gz
iced-23d00445ff1225b3e5ca99cb27966143cda8a2ce.tar.bz2
iced-23d00445ff1225b3e5ca99cb27966143cda8a2ce.zip
Use `saturating_sub` for `last_visible_line` in `text::Editor`
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/text/editor.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs
index 58fcc3dc..fbae287e 100644
--- a/graphics/src/text/editor.rs
+++ b/graphics/src/text/editor.rs
@@ -518,8 +518,9 @@ impl editor::Editor for Editor {
let scroll = buffer.scroll();
let visible_lines = buffer.visible_lines();
- let last_visible_line =
- ((scroll + visible_lines) as usize).min(buffer.lines.len()) - 1;
+ let last_visible_line = ((scroll + visible_lines) as usize)
+ .min(buffer.lines.len())
+ .saturating_sub(1);
let current_line = highlighter.current_line();