Merge pull request #70 from RLHerbert/master
Fix panic when buffer larger than terminal width
This commit is contained in:
commit
3c7729906c
1 changed files with 3 additions and 2 deletions
|
@ -143,8 +143,9 @@ impl View {
|
|||
}
|
||||
}
|
||||
|
||||
let row = line - self.first_line as usize;
|
||||
let col = col - self.first_col as usize;
|
||||
// It is possible for underflow to occur if the buffer length is larger than the terminal width.
|
||||
let row = line.saturating_sub(self.first_line);
|
||||
let col = col.saturating_sub(self.first_col);
|
||||
|
||||
Some(Position::new(row, col))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue