From d7e162892a89ced0a7a2c5456dc83478eaf266b3 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Fri, 14 Feb 2025 20:23:19 +0100 Subject: [PATCH] refactor: use an enum to select move_to_char direction instead of a bool --- src/keybind/builtin/flow.json | 4 ++-- src/tui/mode/mini/move_to_char.zig | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/keybind/builtin/flow.json b/src/keybind/builtin/flow.json index 79439e2..14d8500 100644 --- a/src/keybind/builtin/flow.json +++ b/src/keybind/builtin/flow.json @@ -30,8 +30,8 @@ ["ctrl+l", "scroll_view_center_cycle"], ["ctrl+n", "goto_next_match"], ["ctrl+p", "goto_prev_match"], - ["ctrl+b", "move_to_char", false], - ["ctrl+t", "move_to_char", true], + ["ctrl+b", "move_to_char", "left"], + ["ctrl+t", "move_to_char", "right"], ["ctrl+x", "cut"], ["ctrl+c", "copy"], ["ctrl+v", "system_paste"], diff --git a/src/tui/mode/mini/move_to_char.zig b/src/tui/mode/mini/move_to_char.zig index ad90339..3cc5341 100644 --- a/src/tui/mode/mini/move_to_char.zig +++ b/src/tui/mode/mini/move_to_char.zig @@ -30,13 +30,13 @@ const Operation = enum { }; pub fn create(allocator: Allocator, ctx: command.Context) !struct { tui.Mode, tui.MiniMode } { - var right: bool = true; + var direction: Direction = undefined; const select = if (tui.get_active_editor()) |editor| if (editor.get_primary().selection) |_| true else false else false; - _ = ctx.args.match(.{tp.extract(&right)}) catch return error.InvalidMoveToCharArgument; + _ = ctx.args.match(.{tp.extract(&direction)}) catch return error.InvalidMoveToCharArgument; const self: *Self = try allocator.create(Self); self.* = .{ .allocator = allocator, - .direction = if (right) .right else .left, + .direction = direction, .operation = if (select) .select else .move, }; try self.commands.init(self);