fix crash for small files
This commit is contained in:
parent
586354509b
commit
ad6e458812
1 changed files with 2 additions and 1 deletions
|
@ -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()];
|
||||
|
|
Loading…
Reference in a new issue