Merge pull request #70 from RLHerbert/master
Fix panic when buffer larger than terminal width
commit3c7729906c9a677d715f2694c16cd78200691aaf
authorBlaž Hrastnik <blaz@mxxn.io>
dateThu 3 Jun 2021, 10:28 (5 years ago)
parent7761c881b67fae
helix-view/src/view.rs+3−2
@@ -143,8 +143,9 @@ impl View {
143143 }
144144 }
145145
146− let row = line - self.first_line as usize;
147− let col = col - self.first_col as usize;
146+ // It is possible for underflow to occur if the buffer length is larger than the terminal width.
147+ let row = line.saturating_sub(self.first_line);
148+ let col = col.saturating_sub(self.first_col);
148149
149150 Some(Position::new(row, col))
150151 }