refactor: add Editor.with_cursels_const_repeat

This commit is contained in:
CJ van den Berg 2025-11-27 11:28:00 +01:00
parent c7c271e903
commit f99e10652c
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -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);
}