mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 03:44:04 +08:00
Remove redundant default escape delay
When a terminal sends \x1ba, that could be either escape,a or alt-a.
Historically we've handled this with an escape delay that defaults to 30
milliseconds. If we read nothing for that time, it's escape. Otherwise it's
an alt modifier (or an escape sequence).
As a side effect of 8bf8b10f6
(Extended & human-friendly keys, 2024-03-30) we
added a new way of disambiguating escape: whenever we read the escape byte,
we immediately try another (nonblocking) read. If it succeeds, we treat it
as modifier, else it's escape. Before that commit, we didn't have a concept
of modifiers.
The new way works fine for disambiguating escape,a from alt-a (as pressed
by the user) because only for alt-a the data is sent in the same packet.
So we no longer need the escape delay to disambiguate the alt from the
escape key. Let's simplify things by not using it by default.
The escape delay as set by fish_escape_delay_ms also serves another purpose;
it allows to disambiguate "escape,a" from "escape (pause) a". For that use
case we want to keep it.
This commit is contained in:
parent
1da2087038
commit
b815319607
|
@ -279,8 +279,7 @@ impl CharEvent {
|
|||
/// Time in milliseconds to wait for another byte to be available for reading
|
||||
/// after \x1B is read before assuming that escape key was pressed, and not an
|
||||
/// escape sequence.
|
||||
const WAIT_ON_ESCAPE_DEFAULT: usize = 30;
|
||||
static WAIT_ON_ESCAPE_MS: AtomicUsize = AtomicUsize::new(WAIT_ON_ESCAPE_DEFAULT);
|
||||
static WAIT_ON_ESCAPE_MS: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
const WAIT_ON_SEQUENCE_KEY_INFINITE: usize = usize::MAX;
|
||||
static WAIT_ON_SEQUENCE_KEY_MS: AtomicUsize = AtomicUsize::new(WAIT_ON_SEQUENCE_KEY_INFINITE);
|
||||
|
@ -382,7 +381,7 @@ fn readb(in_fd: RawFd, blocking: bool) -> ReadbResult {
|
|||
pub fn update_wait_on_escape_ms(vars: &EnvStack) {
|
||||
let fish_escape_delay_ms = vars.get_unless_empty(L!("fish_escape_delay_ms"));
|
||||
let Some(fish_escape_delay_ms) = fish_escape_delay_ms else {
|
||||
WAIT_ON_ESCAPE_MS.store(WAIT_ON_ESCAPE_DEFAULT, Ordering::Relaxed);
|
||||
WAIT_ON_ESCAPE_MS.store(0, Ordering::Relaxed);
|
||||
return;
|
||||
};
|
||||
let fish_escape_delay_ms = fish_escape_delay_ms.as_string();
|
||||
|
@ -1000,6 +999,10 @@ pub trait InputEventQueuer {
|
|||
}
|
||||
|
||||
fn readch_timed_esc(&mut self) -> Option<CharEvent> {
|
||||
let wait_ms = WAIT_ON_ESCAPE_MS.load(Ordering::Relaxed);
|
||||
if wait_ms == 0 {
|
||||
return None;
|
||||
}
|
||||
self.readch_timed(WAIT_ON_ESCAPE_MS.load(Ordering::Relaxed))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user