summaryrefslogtreecommitdiff
path: root/src/state/editor/buffer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/editor/buffer.rs')
-rw-r--r--src/state/editor/buffer.rs10
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();