From d80586e262b9d60dd2c0c42f8445a52247e12079 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Sun, 11 Jan 2015 11:36:34 -0800 Subject: [PATCH] Fixed bug in cursor movement code that would result in crashes. --- src/editor.rs | 7 +++---- todo.md | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index 9b0b0b1..fde95a6 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -377,10 +377,9 @@ impl Editor { } pub fn cursor_right(&mut self, n: usize) { - if self.cursor.range.1 <= (self.buffer.grapheme_count() - n) { - self.cursor.range.1 += n; - } - else { + self.cursor.range.1 += n; + + if self.cursor.range.1 > self.buffer.grapheme_count() { self.cursor.range.1 = self.buffer.grapheme_count(); } diff --git a/todo.md b/todo.md index ff680d6..b1ef588 100644 --- a/todo.md +++ b/todo.md @@ -3,8 +3,8 @@ - Line number display - File opening by entering path - UI that wraps editors, for split view. -- Redo functionality - +- Persistent infinite undo +- "Projects" - Clean up text buffer interface: - Editing (these are undoable):