Merge pull request #70 from RLHerbert/master

Fix panic when buffer larger than terminal width
imgbot
Blaž Hrastnik 4 years ago committed by GitHub
commit 3c7729906c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -143,8 +143,9 @@ impl View {
} }
} }
let row = line - self.first_line as usize; // It is possible for underflow to occur if the buffer length is larger than the terminal width.
let col = col - self.first_col as usize; let row = line.saturating_sub(self.first_line);
let col = col.saturating_sub(self.first_col);
Some(Position::new(row, col)) Some(Position::new(row, col))
} }

Loading…
Cancel
Save