refactor: use an enum to select move_to_char direction instead of a bool
This commit is contained in:
parent
0bd34279a8
commit
d7e162892a
2 changed files with 5 additions and 5 deletions
|
@ -30,8 +30,8 @@
|
||||||
["ctrl+l", "scroll_view_center_cycle"],
|
["ctrl+l", "scroll_view_center_cycle"],
|
||||||
["ctrl+n", "goto_next_match"],
|
["ctrl+n", "goto_next_match"],
|
||||||
["ctrl+p", "goto_prev_match"],
|
["ctrl+p", "goto_prev_match"],
|
||||||
["ctrl+b", "move_to_char", false],
|
["ctrl+b", "move_to_char", "left"],
|
||||||
["ctrl+t", "move_to_char", true],
|
["ctrl+t", "move_to_char", "right"],
|
||||||
["ctrl+x", "cut"],
|
["ctrl+x", "cut"],
|
||||||
["ctrl+c", "copy"],
|
["ctrl+c", "copy"],
|
||||||
["ctrl+v", "system_paste"],
|
["ctrl+v", "system_paste"],
|
||||||
|
|
|
@ -30,13 +30,13 @@ const Operation = enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, ctx: command.Context) !struct { tui.Mode, tui.MiniMode } {
|
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;
|
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);
|
const self: *Self = try allocator.create(Self);
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.direction = if (right) .right else .left,
|
.direction = direction,
|
||||||
.operation = if (select) .select else .move,
|
.operation = if (select) .select else .move,
|
||||||
};
|
};
|
||||||
try self.commands.init(self);
|
try self.commands.init(self);
|
||||||
|
|
Loading…
Add table
Reference in a new issue