diff --git a/src/tui/editor.zig b/src/tui/editor.zig index f01342f..a385b86 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -120,11 +120,11 @@ pub const CurSel = struct { return if (self.selection) |*sel| sel else unreachable; } - fn to_selection(self: *const Self) Selection { + pub fn to_selection(self: *const Self) Selection { return self.selection orelse Selection.from_cursor(&self.cursor); } - fn to_selection_inclusive(self: *const Self, root: Buffer.Root, metrics: Buffer.Metrics) Selection { + pub fn to_selection_inclusive(self: *const Self, root: Buffer.Root, metrics: Buffer.Metrics) Selection { return self.selection orelse Selection.from_cursor_inclusive(&self.cursor, root, metrics); } diff --git a/src/tui/mode/helix.zig b/src/tui/mode/helix.zig index 57e3796..b4260cf 100644 --- a/src/tui/mode/helix.zig +++ b/src/tui/mode/helix.zig @@ -285,9 +285,12 @@ const cmds_ = struct { } pub const extend_line_below_meta: Meta = .{ .arguments = &.{.integer}, .description = "Select current line, if already selected, extend to next line" }; - pub fn init_helix_select_mode(_: *Self, _: Context) Result { - _, const ed = get_context() orelse return; - try ed.enable_selection(.{}); + pub fn init_helix_select_mode(self: *Self, _: Context) Result { + const root = try self.buf_root(); + for (self.cursels.items) |*cursel_| { + if (cursel_.*) |*cursel| + cursel.selection = Selection.from_cursor_inclusive(&cursel.cursor, root, self.metrics); + } } pub const init_helix_select_mode_meta: Meta = .{};