diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2024-08-03 10:30:14 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2024-08-03 10:30:14 +0200 |
| commit | cd907dd59a48c2aa9d602aa3fb2f24563994420e (patch) | |
| tree | 33a1d783dc98a09b09fdcaf039bdcee9912dadd5 /src/state/editor/buffer.rs | |
| parent | eafde55afcdf9dc4c17c6c97c1db472fc9ff9957 (diff) | |
implement into_luamulti for cursor move
Diffstat (limited to 'src/state/editor/buffer.rs')
| -rw-r--r-- | src/state/editor/buffer.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/state/editor/buffer.rs b/src/state/editor/buffer.rs index 49c27b9..6e210ab 100644 --- a/src/state/editor/buffer.rs +++ b/src/state/editor/buffer.rs @@ -52,6 +52,10 @@ impl Buffer { } pub fn insert(&mut self, c: char) { + if self.lines.is_empty() { + return; + } + match c { '\n' => { let (a, b) = { @@ -96,6 +100,10 @@ impl Buffer { } pub fn delete(&mut self) { + if self.lines.is_empty() { + return; + } + if self.cursor.is_at_start() && !self.cursor.is_at_top() { let old_line = self.current_line_mut().clone(); self.lines.remove(self.cursor.y()); @@ -108,7 +116,7 @@ impl Buffer { .move_checked(CursorMove::Jump((new_x, self.cursor.y()))); self.refresh_buffer_max() - } else if !self.cursor.is_at_top() { + } else if !self.cursor.is_at_start() { let x = self.cursor.x() - 1; self.current_line_mut().remove(x); self.refresh_line_max(); |