diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 758c8d8..779e2c4 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -1901,7 +1901,7 @@ pub const Editor = struct { }; } - fn cancel_all_selections(self: *Self) void { + pub fn cancel_all_selections(self: *Self) void { var primary = self.get_primary().*; primary.disable_selection(self.buf_root() catch return, self.metrics); self.cursels.clearRetainingCapacity(); @@ -1911,7 +1911,7 @@ pub const Editor = struct { }; } - fn cancel_all_matches(self: *Self) void { + pub fn cancel_all_matches(self: *Self) void { self.matches.clearAndFree(self.allocator); self.match_type = .none; } diff --git a/src/tui/mode/helix.zig b/src/tui/mode/helix.zig index 48de130..b40d4ab 100644 --- a/src/tui/mode/helix.zig +++ b/src/tui/mode/helix.zig @@ -488,6 +488,16 @@ const cmds_ = struct { ed.need_render(); } pub const replace_with_character_helix_meta: Meta = .{ .description = "Replace with character" }; + + pub fn keep_primary_selection(_: *void, _: Ctx) Result { + const mv = tui.mainview() orelse return; + const ed = mv.get_active_editor() orelse return; + const primary = ed.get_primary().*; + ed.cancel_all_selections(); + ed.cancel_all_matches(); + ed.get_primary().* = primary; + } + pub const keep_primary_selection_meta: Meta = .{}; }; fn match_bracket(root: Buffer.Root, cursel: *CurSel, ctx: command.Context, metrics: Buffer.Metrics) error{Stop}!void {