Fix bad EOF behavior
This commit is contained in:
parent
d1693de12b
commit
0192cbbc6b
|
@ -45,6 +45,11 @@ impl Buffer {
|
|||
out.execute(cursor::MoveTo(0, 0))?;
|
||||
|
||||
for (row, line) in (0..rows).zip(self.text.lines_at(scroll.line)) {
|
||||
// only the last line is empty and should be skipped
|
||||
if line.len_chars() == 0 {
|
||||
break;
|
||||
}
|
||||
|
||||
let row = row as usize + scroll.line;
|
||||
write!(out, "{:width$} ", row, width = lr_width as usize)?;
|
||||
|
||||
|
@ -89,7 +94,7 @@ impl Buffer {
|
|||
}
|
||||
}
|
||||
Direction::Down => {
|
||||
if cursor.line < self.text.len_lines() {
|
||||
if cursor.line + 2 < self.text.len_lines() {
|
||||
cursor.line += 1;
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +106,7 @@ impl Buffer {
|
|||
Direction::Right => {
|
||||
let line = self.text.line(cursor.line);
|
||||
if cursor.column + 2 > line.len_chars() {
|
||||
if enable_linewrap && cursor.line < self.text.len_lines() {
|
||||
if enable_linewrap && cursor.line + 2 < self.text.len_lines() {
|
||||
cursor.line += 1;
|
||||
cursor.column = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue