From eba444c6fc804713d7cab81fbea84d0695e951d0 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 27 Nov 2025 20:13:34 +0100 Subject: [PATCH] refactor: eliminate redundent healper function --- src/tui/mode/helix.zig | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/tui/mode/helix.zig b/src/tui/mode/helix.zig index 76dd387..ca9a4f0 100644 --- a/src/tui/mode/helix.zig +++ b/src/tui/mode/helix.zig @@ -313,12 +313,16 @@ const cmds_ = struct { pub const extend_next_long_word_start_meta: Meta = .{ .description = "Extend next long word start", .arguments = &.{.integer} }; pub fn move_prev_word_start(self: *Self, ctx: Context) Result { - try move_cursels_const_repeat(self, move_cursor_prev_word_start, ctx); + const root = try self.buf_root(); + try self.with_cursels_const_repeat(root, move_cursor_prev_word_start, ctx); + self.clamp(); } pub const move_prev_word_start_meta: Meta = .{ .description = "Move previous word start", .arguments = &.{.integer} }; pub fn extend_prev_word_start(self: *Self, ctx: Context) Result { - try move_cursels_const_repeat(self, move_cursor_prev_word_start_extend, ctx); + const root = try self.buf_root(); + try self.with_cursels_const_repeat(root, move_cursor_prev_word_start_extend, ctx); + self.clamp(); } pub const extend_prev_word_start_meta: Meta = .{ .description = "Extend previous word start", .arguments = &.{.integer} }; @@ -602,12 +606,6 @@ fn move_cursor_prev_word_start_extend(root: Buffer.Root, cursel: *CurSel, metric try move_cursor_prev_word_start(root, cursel, metrics); } -fn move_cursels_const_repeat(self: *Self, move: Editor.cursel_operator_const, ctx: Context) Result { - const root = try self.buf_root(); - try self.with_cursels_const_repeat(root, move, ctx); - self.clamp(); -} - fn match_bracket(root: Buffer.Root, cursel: *CurSel, ctx: command.Context, metrics: Buffer.Metrics) error{Stop}!void { var symbol: []const u8 = undefined; const mode: enum { helix_sel_mode, helix_nor_mode } = if ((ctx.args.match(.{tp.extract(&symbol)}) catch false) and