aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorNathan Vegdahl2021-07-26 17:51:00 +0000
committerNathan Vegdahl2021-07-26 17:51:00 +0000
commit5ee6ba5b38ebeb86006bb2e42734a2285eb354df (patch)
treec86575d25773c04cedecd023235aec5c00edee7c /helix-view/src
parent01247acf0cd06fcb3ba3b033e215b9b13b632816 (diff)
Address some PR comments.
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/view.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index e90d0eab..6b0c3c2a 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -92,17 +92,17 @@ impl View {
let line = pos.row;
let col = pos.col;
let height = self.area.height.saturating_sub(1); // - 1 for statusline
- let last_line = self.first_line + height as usize;
+ let last_line = (self.first_line + height as usize).saturating_sub(1);
let scrolloff = PADDING.min(self.area.height as usize / 2); // TODO: user pref
// TODO: not ideal
const OFFSET: usize = 7; // 1 diagnostic + 5 linenr + 1 gutter
- let last_col = self.first_col + (self.area.width as usize - OFFSET);
+ let last_col = (self.first_col + self.area.width as usize).saturating_sub(OFFSET + 1);
- if line > last_line.saturating_sub(scrolloff + 1) {
+ if line > last_line.saturating_sub(scrolloff) {
// scroll down
- self.first_line += line - (last_line.saturating_sub(scrolloff + 1));
+ self.first_line += line - (last_line.saturating_sub(scrolloff));
} else if line < self.first_line + scrolloff {
// scroll up
self.first_line = line.saturating_sub(scrolloff);