From e42f3ff3a581936d746684490a8c1cc8d06a82b5 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 30 Oct 2025 11:19:58 +0100 Subject: [PATCH] refactor: use select_line_at_cursor to simplify cut_internal_vim --- src/tui/editor.zig | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index b6f3087..feb5ffe 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -2678,13 +2678,8 @@ pub const Editor = struct { const primary = self.get_primary(); const b = self.buf_for_update() catch return; var root = b.root; - if (self.cursels.items.len == 1) - if (primary.selection) |_| {} else { - const sel = primary.enable_selection(root, self.metrics) catch return; - try move_cursor_begin(root, &sel.begin, self.metrics); - try move_cursor_end(root, &sel.end, self.metrics); - try move_cursor_right(root, &sel.end, self.metrics); - }; + if (self.cursels.items.len == 1 and primary.selection == null) + try self.select_line_at_cursor(root, primary, .include_eol); for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| { const cut_text, root = try self.cut_selection(root, cursel, tui.clipboard_allocator()); tui.clipboard_add_chunk(cut_text);