fix crash for small files

This commit is contained in:
Crispy 2023-02-26 21:14:47 +01:00
parent 586354509b
commit ad6e458812

View file

@ -171,7 +171,8 @@ impl Editor {
print!("{}", clear::All);
let max_rows = terminal_size().unwrap().1 as usize - 1;
let visible_rows = self.scroll..(self.scroll + max_rows);
let end = (self.scroll + max_rows).min(self.lines.len());
let visible_rows = self.scroll..end;
for (line_index, line) in self.lines[visible_rows].iter().enumerate() {
let text = &self.text[line.clone()];