feat: implement helix search_selection and add_next_match_helix

This commit is contained in:
CJ van den Berg 2025-12-04 17:33:43 +01:00
parent 791b184583
commit 58622a5531
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
3 changed files with 35 additions and 7 deletions

View file

@ -498,6 +498,30 @@ const cmds_ = struct {
ed.get_primary().* = primary;
}
pub const keep_primary_selection_meta: Meta = .{};
pub fn search_selection(_: *void, _: Ctx) Result {
const mv = tui.mainview() orelse return;
const ed = mv.get_active_editor() orelse return;
const sel = ed.get_primary().selection orelse {
ed.logger.print("no selection", .{});
return;
};
const query = try ed.get_selection(sel, ed.allocator);
defer ed.allocator.free(query);
ed.match_type = .find;
ed.set_last_find_query(query, .find);
ed.logger.print("set find register to '{s}'", .{query});
}
pub const search_selection_meta: Meta = .{};
pub fn add_next_match_helix(_: *void, _: Ctx) Result {
const mv = tui.mainview() orelse return;
const ed = mv.get_active_editor() orelse return;
if (ed.matches.items.len == 0)
try ed.repeat_last_find();
try ed.add_cursor_next_match(.{});
}
pub const add_next_match_helix_meta: Meta = .{};
};
fn match_bracket(root: Buffer.Root, cursel: *CurSel, ctx: command.Context, metrics: Buffer.Metrics) error{Stop}!void {