feat: add optional integer arguments to goto and goto_offset commands
This commit is contained in:
parent
2461717f11
commit
4035cefcaf
1 changed files with 21 additions and 4 deletions
|
@ -1034,14 +1034,31 @@ const cmds = struct {
|
|||
pub const find_in_files_meta: Meta = .{ .description = "Find in files" };
|
||||
|
||||
pub fn goto(self: *Self, ctx: Ctx) Result {
|
||||
return enter_mini_mode(self, @import("mode/mini/goto.zig"), ctx);
|
||||
var line: usize = undefined;
|
||||
var column: usize = undefined;
|
||||
return if (try ctx.args.match(.{tp.extract(&line)}))
|
||||
command.executeName("goto_line", command.fmt(.{line}))
|
||||
else if (try ctx.args.match(.{ tp.extract(&line), tp.extract(&column) }))
|
||||
command.executeName("goto_line_and_column", command.fmt(.{ line, column }))
|
||||
else
|
||||
enter_mini_mode(self, @import("mode/mini/goto.zig"), ctx);
|
||||
}
|
||||
pub const goto_meta: Meta = .{ .description = "Goto line" };
|
||||
pub const goto_meta: Meta = .{
|
||||
.description = "Goto line",
|
||||
.arguments = &.{ .integer, .integer },
|
||||
};
|
||||
|
||||
pub fn goto_offset(self: *Self, ctx: Ctx) Result {
|
||||
return enter_mini_mode(self, @import("mode/mini/goto_offset.zig"), ctx);
|
||||
var offset: usize = undefined;
|
||||
return if (try ctx.args.match(.{tp.extract(&offset)}))
|
||||
command.executeName("goto_byte_offset", command.fmt(.{offset}))
|
||||
else
|
||||
enter_mini_mode(self, @import("mode/mini/goto_offset.zig"), ctx);
|
||||
}
|
||||
pub const goto_offset_meta: Meta = .{ .description = "Goto byte offset" };
|
||||
pub const goto_offset_meta: Meta = .{
|
||||
.description = "Goto byte offset",
|
||||
.arguments = &.{.integer},
|
||||
};
|
||||
|
||||
pub fn move_to_char(self: *Self, ctx: Ctx) Result {
|
||||
return enter_mini_mode(self, @import("mode/mini/move_to_char.zig"), ctx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue