fix: clamp scroll.line to a valid range
This commit is contained in:
parent
9a2ab09f06
commit
83e8bd237a
1 changed files with 7 additions and 0 deletions
|
|
@ -573,6 +573,13 @@ impl Buffer {
|
|||
return;
|
||||
}
|
||||
let metrics = self.metrics;
|
||||
|
||||
// Clamp scroll.line to valid range (lines may have been removed by editing)
|
||||
if self.scroll.line >= self.lines.len() {
|
||||
self.scroll.line = self.lines.len().saturating_sub(1);
|
||||
self.scroll.vertical = 0.0;
|
||||
}
|
||||
|
||||
let old_scroll = self.scroll;
|
||||
|
||||
loop {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue