From f99e10652cda71cae166bfdf4bceff2b50bd6cf1 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 27 Nov 2025 11:28:00 +0100 Subject: [PATCH] refactor: add Editor.with_cursels_const_repeat --- src/tui/editor.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index fd417c0..5e34ca3 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -2117,6 +2117,21 @@ pub const Editor = struct { return if (someone_stopped) error.Stop else {}; } + pub fn with_cursels_const_repeat(self: *Self, root: Buffer.Root, move: cursel_operator_const, ctx: Context) error{Stop}!void { + var someone_stopped = false; + 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| + with_cursel_const(root, move, cursel, self.metrics) catch { + someone_stopped = true; + }; + self.collapse_cursors(); + if (someone_stopped) break; + } + return if (someone_stopped) error.Stop else {}; + } + fn with_cursel_mut_arg(self: *Self, root: Buffer.Root, op: cursel_operator_mut_arg, cursel: *CurSel, allocator: Allocator, ctx: Context) error{Stop}!Buffer.Root { return op(self, root, cursel, allocator, ctx); }