mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-21 11:31:15 -03:00
Increase timeout when reading escape sequences inside paste/kitty kbd
Historically, fish has treated input bytes [0x1b, 'b'] as alt-b (rather than
"escape,b") if the second byte arrives within 30ms of the first.
Since we made builtin bind match key events instead of raw byte sequences,
we have another place where we do similar disambiguation: when we read keys
such as alt-left ("\e[1;3D"), we only consider bytes to be part of this
sequence if stdin is immediately readable (actually "readable after a 1ms
timeout" since e1be842 (Work around torn byte sequences in qemu kbd input
with 1ms timeout, 2025-03-04)).
This is technically wrong but has worked in practice (for Kakoune etc.).
Issue #11668 reports two issues on some Windows terminals feeding a remote
fish shell:
- the "bracketed paste finished" sequence may be split into multiple packets,
which causes a delay of > 1ms between individual bytes being readable.
- AutoHotKey scripts simulating seven "left" keys result in sequence tearing
as well.
Try to fix the paste case by increasing the timeout when parsing escape
sequences.
Also increase the timeout for terminals that support the kitty keyboard
protocol. The user should only notice this new delay after pressing one of
escape,O, escape,P, escape,[, or escape,] **while the kitty keyboard protocol
is disabled** (e.g. while an external command is running). In this case,
the fish_escape_delay_ms is also virtually increased; hopefully this edge
case is not ever relevant.
Part of #11668
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
use crate::reader::{reader_save_screen_state, reader_test_and_clear_interrupted};
|
||||
use crate::terminal::{Capability, SCROLL_FORWARD_SUPPORTED, SCROLL_FORWARD_TERMINFO_CODE};
|
||||
use crate::threads::iothread_port;
|
||||
use crate::tty_handoff::set_kitty_keyboard_capability;
|
||||
use crate::tty_handoff::{get_kitty_keyboard_capability, set_kitty_keyboard_capability};
|
||||
use crate::universal_notifier::default_notifier;
|
||||
use crate::wchar::{encode_byte_to_char, prelude::*};
|
||||
use crate::wutil::encoding::{mbrtowc, mbstate_t, zero_mbstate};
|
||||
@@ -905,7 +905,22 @@ fn readch(&mut self) -> CharEvent {
|
||||
|
||||
fn try_readb(&mut self, buffer: &mut Vec<u8>) -> Option<u8> {
|
||||
let fd = self.get_in_fd();
|
||||
if !check_fd_readable(fd, Duration::from_millis(1)) {
|
||||
if !check_fd_readable(
|
||||
fd,
|
||||
Duration::from_millis(
|
||||
if self.paste_is_buffering()
|
||||
|| get_kitty_keyboard_capability() == Capability::Supported
|
||||
{
|
||||
300
|
||||
} else {
|
||||
1
|
||||
},
|
||||
),
|
||||
) {
|
||||
FLOG!(
|
||||
reader,
|
||||
format!("Incomplete escape sequence: {}", DisplayBytes(buffer))
|
||||
);
|
||||
return None;
|
||||
}
|
||||
let next = readb(fd)?;
|
||||
|
||||
Reference in New Issue
Block a user