feat: add repeat argument to delete_line

This commit is contained in:
CJ van den Berg 2025-10-30 12:54:47 +01:00
parent fc8642768d
commit 21d1555aca
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -3015,22 +3015,26 @@ pub const Editor = struct {
} }
pub const delete_to_end_meta: Meta = .{ .description = "Delete to end of line" }; 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(); const b = try self.buf_for_update();
var root = b.root; var root = b.root;
for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| { var repeat: usize = 1;
const col = cursel.cursor.col; _ = ctx.args.match(.{tp.extract(&repeat)}) catch false;
const target = cursel.cursor.target; while (repeat > 0) : (repeat -= 1) {
try self.select_line_at_cursor(root, cursel, .include_eol); for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| {
root = try self.delete_selection(root, cursel, b.allocator); const col = cursel.cursor.col;
cursel.cursor.col = col; const target = cursel.cursor.target;
cursel.cursor.target = target; try self.select_line_at_cursor(root, cursel, .include_eol);
cursel.cursor.clamp_to_buffer(root, self.metrics); 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); try self.update_buf(root);
self.clamp(); 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 { pub fn cut_to_end_vim(self: *Self, _: Context) Result {
const b = try self.buf_for_update(); const b = try self.buf_for_update();