Compare commits

...

3 commits

3 changed files with 32 additions and 0 deletions

View file

@ -55,6 +55,8 @@ pub const whitespace = struct {
};
};
pub const PosType = enum { column, byte };
pub const Match = struct {
begin: Cursor = Cursor{},
end: Cursor = Cursor{},
@ -5410,11 +5412,18 @@ pub const Editor = struct {
var column: usize = 0;
var have_sel: bool = false;
var sel: Selection = .{};
var pos_type: PosType = .column;
if (try ctx.args.match(.{
tp.extract(&line),
tp.extract(&column),
})) {
// self.logger.print("goto: l:{d} c:{d}", .{ line, column });
} else if (try ctx.args.match(.{
tp.extract(&line),
tp.extract(&column),
tp.extract(&pos_type),
})) {
// self.logger.print("goto: l:{d} c:{d}", .{ line, column });
} else if (try ctx.args.match(.{
tp.extract(&line),
tp.extract(&column),
@ -5425,9 +5434,29 @@ pub const Editor = struct {
})) {
// self.logger.print("goto: l:{d} c:{d} {any}", .{ line, column, sel });
have_sel = true;
} else if (try ctx.args.match(.{
tp.extract(&line),
tp.extract(&column),
tp.extract(&sel.begin.row),
tp.extract(&sel.begin.col),
tp.extract(&sel.end.row),
tp.extract(&sel.end.col),
tp.extract(&pos_type),
})) {
// self.logger.print("goto: l:{d} c:{d} {any} {}", .{ line, column, sel, pos_type });
have_sel = true;
} else return error.InvalidGotoLineAndColumnArgument;
self.cancel_all_selections();
const root = self.buf_root() catch return;
if (pos_type == .byte) {
column = root.pos_to_width(line - 1, column - 1, self.metrics) catch return;
column += 1;
if (have_sel) {
sel.begin.col = root.pos_to_width(sel.begin.row, sel.begin.col, self.metrics) catch return;
sel.end.col = root.pos_to_width(sel.end.row, sel.end.col, self.metrics) catch return;
}
// self.logger.print("goto_byte_pos: l:{d} c:{d} {any} {}", .{ line, column, sel, pos_type });
}
const primary = self.get_primary();
try primary.cursor.move_to(
root,

View file

@ -46,6 +46,7 @@ const Entry = struct {
end_pos: usize,
lines: []const u8,
severity: editor.Diagnostic.Severity = .Information,
pos_type: editor.PosType,
};
pub fn create(allocator: Allocator, parent: Plane) !Widget {
@ -250,6 +251,7 @@ fn handle_menu_action(menu: **Menu.State(*Self), button: *Button.State(*Menu.Sta
if (entry.begin_pos == 0) 0 else entry.begin_pos + 1,
entry.end_line,
entry.end_pos + 1,
entry.pos_type,
},
} }) catch |e| self.logger.err("navigate", e);
}

View file

@ -1423,6 +1423,7 @@ fn add_find_in_files_result(
.end_pos = @max(1, end_pos) - 1,
.lines = lines,
.severity = severity,
.pos_type = .byte,
}) catch |e| return tp.exit_error(e, @errorReturnTrace());
}