feat: make goto in flow select mode select to line

This commit is contained in:
CJ van den Berg 2025-12-16 15:09:58 +01:00
parent a9ee5321ac
commit 0dcf63bd38
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
3 changed files with 32 additions and 4 deletions

View file

@ -1,4 +1,5 @@
const fmt = @import("std").fmt;
const cbor = @import("cbor");
const command = @import("command");
const tui = @import("../../tui.zig");
@ -83,10 +84,20 @@ pub const preview = goto;
pub const apply = goto;
pub const cancel = goto;
fn goto(self: *Type, _: command.Context) void {
send_goto(if (self.input) |input| input.cursor else self.start.cursor);
const Mode = enum {
goto,
select,
};
fn goto(self: *Type, ctx: command.Context) void {
var mode: Mode = .goto;
_ = ctx.args.match(.{cbor.extract(&mode)}) catch {};
send_goto(mode, if (self.input) |input| input.cursor else self.start.cursor);
}
fn send_goto(cursor: Cursor) void {
command.executeName("goto_line_and_column", command.fmt(.{ cursor.row, cursor.col })) catch {};
fn send_goto(mode: Mode, cursor: Cursor) void {
switch (mode) {
.goto => command.executeName("goto_line_and_column", command.fmt(.{ cursor.row, cursor.col })) catch {},
.select => command.executeName("select_to_line", command.fmt(.{cursor.row})) catch {},
}
}