From 4087e0a3f95b1ed50d93eb4c080b65dbdffe1319 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 30 Oct 2025 11:38:50 +0100 Subject: [PATCH] fix: preserve cursor column and target in delete_line This is the expected behaviour (for me at least) and makes delete_line significantly more useful than plain `cut` with no selection. closes #342 --- src/tui/editor.zig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index feb5ffe..90d1d67 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -3019,8 +3019,13 @@ pub const Editor = struct { const b = try self.buf_for_update(); var root = b.root; for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| { + const col = cursel.cursor.col; + const target = cursel.cursor.target; try self.select_line_at_cursor(root, cursel, .include_eol); root = try self.delete_selection(root, cursel, b.allocator); + cursel.cursor.col = col; + cursel.cursor.target = target; + cursel.cursor.clamp_to_buffer(root, self.metrics); }; try self.update_buf(root); self.clamp();