From fa59dc1ff8fb4ac267dc0a5235f195613b575819 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 25 Jun 2024 21:10:19 +0200 Subject: [PATCH] fix(goto): avoid getting stuck in fast scroll when in goto mode --- src/tui/mode/mini/goto.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/tui/mode/mini/goto.zig b/src/tui/mode/mini/goto.zig index a22dd90..ef8889f 100644 --- a/src/tui/mode/mini/goto.zig +++ b/src/tui/mode/mini/goto.zig @@ -67,6 +67,7 @@ fn mapEvent(self: *Self, evtype: u32, keypress: u32, modifiers: u32) tp.result { switch (evtype) { event_type.PRESS => try self.mapPress(keypress, modifiers), event_type.REPEAT => try self.mapPress(keypress, modifiers), + event_type.RELEASE => try self.mapRelease(keypress, modifiers), else => {}, } } @@ -84,6 +85,8 @@ fn mapPress(self: *Self, keypress: u32, modifiers: u32) tp.result { else => {}, }, 0 => switch (keypress) { + key.LCTRL, key.RCTRL => command.executeName("enable_fast_scroll", .{}), + key.LALT, key.RALT => command.executeName("enable_fast_scroll", .{}), key.ESC => self.cancel(), key.ENTER => command.executeName("exit_mini_mode", .{}), key.BACKSPACE => if (self.input) |linenum| { @@ -106,6 +109,14 @@ fn mapPress(self: *Self, keypress: u32, modifiers: u32) tp.result { }; } +fn mapRelease(_: *Self, keypress: u32, _: u32) tp.result { + return switch (keypress) { + key.LCTRL, key.RCTRL => command.executeName("disable_fast_scroll", .{}), + key.LALT, key.RALT => command.executeName("disable_fast_scroll", .{}), + else => {}, + }; +} + fn goto(self: *Self) void { command.executeName("goto_line", command.fmt(.{self.input orelse self.start})) catch {}; }