refactor: split editor.insert_chars into insert_chars and insert_cursels

This commit is contained in:
CJ van den Berg 2025-12-09 19:19:39 +01:00
parent 098d925358
commit c462e3abda
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -4626,10 +4626,7 @@ pub const Editor = struct {
}
pub const select_prev_sibling_meta: Meta = .{ .description = "Move selection to previous AST sibling node" };
pub fn insert_chars(self: *Self, ctx: Context) Result {
var chars: []const u8 = undefined;
if (!try ctx.args.match(.{tp.extract(&chars)}))
return error.InvalidInsertCharsArgument;
pub fn insert_cursels(self: *Self, chars: []const u8) Result {
const b = try self.buf_for_update();
var root = b.root;
for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| {
@ -4638,6 +4635,13 @@ pub const Editor = struct {
try self.update_buf(root);
self.clamp();
}
pub fn insert_chars(self: *Self, ctx: Context) Result {
var chars: []const u8 = undefined;
if (!try ctx.args.match(.{tp.extract(&chars)}))
return error.InvalidInsertCharsArgument;
return self.insert_cursels(chars);
}
pub const insert_chars_meta: Meta = .{ .arguments = &.{.string} };
pub fn insert_line(self: *Self, _: Context) Result {