aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-06-03 01:28:14 +0000
committerGitHub2021-06-03 01:28:14 +0000
commit3c7729906c9a677d715f2694c16cd78200691aaf (patch)
tree1985c09391e87746c39c6561b615e4e75f51f1b2 /helix-view
parent7761c88d6130364915daa23115d2ee1234b2bab5 (diff)
parent1b67fae9f4eabf0899dda441971b8a338cb45a15 (diff)
Merge pull request #70 from RLHerbert/master
Fix panic when buffer larger than terminal width
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/src/view.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index f82de90e..b7bfaa17 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -143,8 +143,9 @@ impl View {
}
}
- let row = line - self.first_line as usize;
- let col = col - self.first_col as usize;
+ // It is possible for underflow to occur if the buffer length is larger than the terminal width.
+ let row = line.saturating_sub(self.first_line);
+ let col = col.saturating_sub(self.first_col);
Some(Position::new(row, col))
}