mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 05:53:59 +00:00
Fix fish_escape_delay_ms for terminals that send CSI 27 u
See the parent commit for some context. Turns out that 8bf8b10f6
(Extended &
human-friendly keys, 2024-03-30) broke this for terminals that speak CSI u.
This is pretty complex, probably not worth it.
This commit is contained in:
parent
b815319607
commit
15cd74a3bb
2 changed files with 13 additions and 7 deletions
18
src/input.rs
18
src/input.rs
|
@ -5,8 +5,9 @@ use crate::event;
|
|||
use crate::flog::FLOG;
|
||||
use crate::input_common::{
|
||||
CharEvent, CharInputStyle, InputEventQueuer, ReadlineCmd, R_END_INPUT_FUNCTIONS,
|
||||
WAIT_ON_ESCAPE_MS,
|
||||
};
|
||||
use crate::key::{self, canonicalize_raw_escapes, ctrl, Key};
|
||||
use crate::key::{self, canonicalize_raw_escapes, ctrl, Key, Modifiers};
|
||||
use crate::parser::Parser;
|
||||
use crate::proc::job_reap;
|
||||
use crate::reader::{
|
||||
|
@ -667,6 +668,15 @@ impl EventQueuePeeker<'_> {
|
|||
let Some(kevt) = evt.get_key() else {
|
||||
return false;
|
||||
};
|
||||
if WAIT_ON_ESCAPE_MS.load(Ordering::Relaxed) != 0
|
||||
&& kevt.key == Key::from_raw(key::Escape)
|
||||
&& key.modifiers == Modifiers::ALT
|
||||
{
|
||||
self.idx += 1;
|
||||
self.subidx = 0;
|
||||
FLOG!(reader, "matched delayed escape prefix in alt sequence");
|
||||
return self.next_is_char(Key::from_raw(key.codepoint), true);
|
||||
}
|
||||
if self.subidx == 0 && kevt.key == key {
|
||||
self.idx += 1;
|
||||
return true;
|
||||
|
@ -684,11 +694,7 @@ impl EventQueuePeeker<'_> {
|
|||
// FLOG!(reader, "matched legacy sequence for", key);
|
||||
return true;
|
||||
}
|
||||
if key.modifiers.alt
|
||||
&& !key.modifiers.ctrl
|
||||
&& !key.modifiers.shift
|
||||
&& seq_char == '\x1b'
|
||||
{
|
||||
if key.modifiers == Modifiers::ALT && seq_char == '\x1b' {
|
||||
if self.subidx + 1 == actual_seq.len() {
|
||||
self.idx += 1;
|
||||
self.subidx = 0;
|
||||
|
|
|
@ -279,7 +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.
|
||||
static WAIT_ON_ESCAPE_MS: AtomicUsize = AtomicUsize::new(0);
|
||||
pub(crate) 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);
|
||||
|
|
Loading…
Reference in a new issue