fix(goto): avoid getting stuck in fast scroll when in goto mode

This commit is contained in:
CJ van den Berg 2024-06-25 21:10:19 +02:00
parent a79a49e4b9
commit fa59dc1ff8

View file

@ -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 {};
}