mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-05 16:21:15 -03:00
Allow mapping new-style sequences that start with escape
On Konsole with
function my-bindings
bind --preset --erase escape
bind escape,i 'echo escape i'
end
set fish_key_bindings my-bindings
the "escape,i" binding doesn't trigger. This is because of our special
handling of the escape key prefix. Other multi-key bindings like "bind j,k"
wait indefinitely for the second character. But not "escape,i"; that one
has historically had a low timeout (fish_escape_delay_ms). The motivation
is probably that we have a "escape" binding as well that shouldn't wait
indefinitely.
We can distinguish between the case of raw escape sequence binding like "\e123"
and a binding that talks about the actual escape key like "escape,i". For the
latter we don't need the special treatment of having a low timeout, so make it
fall back to "fish_sequence_key_delay_ms" which waits indefinitely by default.
This commit is contained in:
23
src/input.rs
23
src/input.rs
@@ -653,15 +653,26 @@ fn next_is_char(&mut self, style: &KeyNameStyle, key: Key, escaped: bool) -> boo
|
||||
// Grab a new event if we have exhausted what we have already peeked.
|
||||
// Use either readch or readch_timed, per our param.
|
||||
if self.idx == self.peeked.len() {
|
||||
let Some(newevt) = (if escaped {
|
||||
let newevt = if escaped {
|
||||
FLOG!(reader, "reading timed escape");
|
||||
self.event_queue.readch_timed_esc()
|
||||
match self.event_queue.readch_timed_esc(style) {
|
||||
Ok(evt) => evt,
|
||||
Err(timed_out) => {
|
||||
if timed_out {
|
||||
self.had_timeout = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
FLOG!(reader, "readch timed sequence key");
|
||||
self.event_queue.readch_timed_sequence_key()
|
||||
}) else {
|
||||
self.had_timeout = true;
|
||||
return false;
|
||||
match self.event_queue.readch_timed_sequence_key() {
|
||||
Some(evt) => evt,
|
||||
None => {
|
||||
self.had_timeout = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
FLOG!(reader, format!("adding peeked {:?}", newevt));
|
||||
self.peeked.push(newevt);
|
||||
|
||||
Reference in New Issue
Block a user