feat: add select_to_line_vim command

This commit is contained in:
CJ van den Berg 2025-12-16 15:17:13 +01:00
parent 0dcf63bd38
commit fffedb7371
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -3439,6 +3439,12 @@ pub const Editor = struct {
try cursor.move_to(root, line -| 1, cursor.col, metrics); try cursor.move_to(root, line -| 1, cursor.col, metrics);
} }
fn move_cursor_to_line_vim(root: Buffer.Root, cursor: *Cursor, ctx: Context, metrics: Buffer.Metrics) error{Stop}!void {
var line: usize = 0;
_ = ctx.args.match(.{tp.extract(&line)}) catch false;
try cursor.move_to(root, line -| 1, cursor.col, metrics);
}
fn move_cursor_to_char_left(root: Buffer.Root, cursor: *Cursor, ctx: Context, metrics: Buffer.Metrics) error{Stop}!void { fn move_cursor_to_char_left(root: Buffer.Root, cursor: *Cursor, ctx: Context, metrics: Buffer.Metrics) error{Stop}!void {
var egc: []const u8 = undefined; var egc: []const u8 = undefined;
if (!(ctx.args.match(.{tp.extract(&egc)}) catch return error.Stop)) if (!(ctx.args.match(.{tp.extract(&egc)}) catch return error.Stop))
@ -5768,6 +5774,15 @@ pub const Editor = struct {
} }
pub const goto_line_vim_meta: Meta = .{ .arguments = &.{.integer} }; pub const goto_line_vim_meta: Meta = .{ .arguments = &.{.integer} };
pub fn select_to_line_vim(self: *Self, ctx: Context) Result {
try self.send_editor_jump_source();
const root = self.buf_root() catch return;
self.with_selections_const_arg(root, move_cursor_to_line_vim, ctx) catch {};
self.clamp();
try self.send_editor_jump_destination();
}
pub const select_to_line_vim_meta: Meta = .{ .arguments = &.{.integer} };
pub fn goto_column(self: *Self, ctx: Context) Result { pub fn goto_column(self: *Self, ctx: Context) Result {
const root = self.buf_root() catch return; const root = self.buf_root() catch return;
const primary = self.get_primary(); const primary = self.get_primary();