fix: clamp scroll.line to a valid range

This commit is contained in:
Hojjat 2026-04-09 16:23:39 -06:00 committed by Jeremy Soller
parent 9a2ab09f06
commit 83e8bd237a

View file

@ -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 {