From c7cca545b9ceaf0a66885544caf020ecb63e66c5 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 19 Feb 2025 18:42:14 +0100 Subject: [PATCH] fix: make move_cursor_up/_down fallback to move_begin/_end closes #185 --- src/tui/editor.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 60649c6..158c9d5 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -2083,7 +2083,9 @@ pub const Editor = struct { } fn move_cursor_up(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void { - try cursor.move_up(root, metrics); + cursor.move_up(root, metrics) catch |e| switch (e) { + error.Stop => cursor.move_begin(), + }; } fn move_cursor_up_vim(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void { @@ -2092,7 +2094,9 @@ pub const Editor = struct { } fn move_cursor_down(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void { - try cursor.move_down(root, metrics); + cursor.move_down(root, metrics) catch |e| switch (e) { + error.Stop => cursor.move_end(root, metrics), + }; } fn move_cursor_down_vim(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void {