View mode: Use saturating_sub when calculating first_col
commit4f561e93b8cff364196475a97fb2bfefcd1c7092
authorBlaž Hrastnik <blaz@mxxn.io>
dateMon 7 Jun 2021, 09:29 (5 years ago)
parent01b1bd1
helix-term/src/commands.rs+1−1
@@ -2502,7 +2502,7 @@ pub fn view_mode(cx: &mut Context) {
25022502 let pos = coords_at_pos(doc.text().slice(..), pos);
25032503
25042504 const OFFSET: usize = 7; // gutters
2505− view.first_col = pos.col.saturating_sub((view.area.width as usize - OFFSET) / 2);
2505+ view.first_col = pos.col.saturating_sub(((view.area.width as usize).saturating_sub(OFFSET)) / 2);
25062506 },
25072507 'h' => (),
25082508 'j' => scroll(cx, 1, Direction::Forward),