diff --git a/src/edit/editor.rs b/src/edit/editor.rs index f1c6074..3876855 100644 --- a/src/edit/editor.rs +++ b/src/edit/editor.rs @@ -91,6 +91,7 @@ impl Edit for Editor { if self.cursor != cursor { self.cursor = cursor; self.cursor_moved = true; + self.cursor_x_opt = None; self.buffer.set_redraw(true); } } @@ -854,6 +855,11 @@ impl Edit for Editor { self.cursor.index = self.buffer.lines[self.cursor.line].text().len(); self.cursor_x_opt = None; } + Action::GotoLine(line) => { + let mut cursor = self.buffer.layout_cursor(&self.cursor); + cursor.line = line; + self.set_layout_cursor(font_system, cursor); + } } if old_cursor != self.cursor { diff --git a/src/edit/mod.rs b/src/edit/mod.rs index 3a8041b..9c43a96 100644 --- a/src/edit/mod.rs +++ b/src/edit/mod.rs @@ -89,6 +89,8 @@ pub enum Action { BufferStart, /// Move cursor to the end of the document BufferEnd, + /// Move cursor to specific line + GotoLine(usize), } /// A trait to allow easy replacements of [`Editor`], like `SyntaxEditor`