feat: bar status shows extend or select when on helix mode

This commit is contained in:
Igor Támara 2025-10-28 12:30:33 -05:00 committed by CJ van den Berg
parent f5efe8e94f
commit e76c47e1a6
3 changed files with 79 additions and 3 deletions

View file

@ -484,11 +484,11 @@ fn select_cursel_till_char_left_helix(root: Buffer.Root, cursel: *CurSel, ctx: c
var moving_cursor: Cursor = cursel.*.cursor;
var begin = cursel.*.cursor;
move_cursor_till_char_left_beyond_eol(root, &moving_cursor, metrics, ctx) catch return;
// Character found, selecting
Editor.move_cursor_right(root, &begin, metrics) catch {
//At end of file, it's ok
};
// Character found, selecting
moving_cursor.target = moving_cursor.col;
const sel = try cursel.enable_selection(root, metrics);
sel.begin = begin;

View file

@ -29,6 +29,7 @@ const Direction = enum {
const Operation = enum {
move,
select,
extend,
};
pub fn create(allocator: Allocator, ctx: command.Context) !struct { tui.Mode, tui.MiniMode } {
@ -36,7 +37,18 @@ pub fn create(allocator: Allocator, ctx: command.Context) !struct { tui.Mode, tu
_ = ctx.args.match(.{tp.extract(&operation_command)}) catch return error.InvalidMoveToCharArgument;
const direction: Direction = if (std.mem.indexOf(u8, operation_command, "_left")) |_| .left else .right;
const operation: Operation = if (tui.get_active_editor()) |editor| if (editor.get_primary().selection) |_| .select else .move else .move;
var operation: Operation = undefined;
if (std.mem.indexOf(u8, operation_command, "extend_")) |_| {
operation = .extend;
} else if (std.mem.indexOf(u8, operation_command, "select_")) |_| {
operation = .select;
} else if (tui.get_active_editor()) |editor| if (editor.get_primary().selection) |_| {
operation = .select;
} else {
operation = .move;
} else {
operation = .move;
}
const self = try allocator.create(Self);
errdefer allocator.destroy(self);
@ -70,6 +82,10 @@ fn name(self: *Self) []const u8 {
.left => "󰒅 ↶ select",
.right => "󰒅 ↷ select",
},
.extend => switch (self.direction) {
.left => "󰒅 ↶ extend",
.right => "󰒅 ↷ extend",
},
};
}