fix: init all cursors in init_helix_select_mode

This commit is contained in:
CJ van den Berg 2025-11-27 19:41:34 +01:00
parent 2b27ef3332
commit 839f1b8e38
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 8 additions and 5 deletions

View file

@ -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);
}

View file

@ -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 = .{};