@@ -92,17 +92,17 @@ impl View {
9292 let line = pos.row;
9393 let col = pos.col;
9494 let height = self.area.height.saturating_sub(1); // - 1 for statusline
95− let last_line = self.first_line + height as usize;
95+ let last_line = (self.first_line + height as usize).saturating_sub(1);
9696
9797 let scrolloff = PADDING.min(self.area.height as usize / 2); // TODO: user pref
9898
9999 // TODO: not ideal
100100 const OFFSET: usize = 7; // 1 diagnostic + 5 linenr + 1 gutter
101− let last_col = self.first_col + (self.area.width as usize - OFFSET);
101+ let last_col = (self.first_col + self.area.width as usize).saturating_sub(OFFSET + 1);
102102
103− if line > last_line.saturating_sub(scrolloff + 1) {
103+ if line > last_line.saturating_sub(scrolloff) {
104104 // scroll down
105− self.first_line += line - (last_line.saturating_sub(scrolloff + 1));
105+ self.first_line += line - (last_line.saturating_sub(scrolloff));
106106 } else if line < self.first_line + scrolloff {
107107 // scroll up
108108 self.first_line = line.saturating_sub(scrolloff);