From 21d1555aca158268abb26069ce87541afaf7a868 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 30 Oct 2025 12:54:47 +0100 Subject: [PATCH] feat: add repeat argument to delete_line --- src/tui/editor.zig | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 948ac8b..33d5daf 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -3015,22 +3015,26 @@ pub const Editor = struct { } pub const delete_to_end_meta: Meta = .{ .description = "Delete to end of line" }; - pub fn delete_line(self: *Self, _: Context) Result { + pub fn delete_line(self: *Self, ctx: Context) Result { 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); - }; + var repeat: usize = 1; + _ = ctx.args.match(.{tp.extract(&repeat)}) catch false; + while (repeat > 0) : (repeat -= 1) { + 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(); } - pub const delete_line_meta: Meta = .{ .description = "Delete current line" }; + pub const delete_line_meta: Meta = .{ .description = "Delete current line", .arguments = &.{.integer} }; pub fn cut_to_end_vim(self: *Self, _: Context) Result { const b = try self.buf_for_update();