aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorakbash <akbash@herdr.dev>2026-08-06 14:18:27 +0300
committerGitHub <noreply@github.com>2026-08-06 14:18:27 +0300
commite9222d1882effd62ddae9c4d81bc2d9390da7cac (patch)
treed1a68c3f5521831add0ecff763cd450ca6602fc9 /src
parentfc824b99aba9389ffda75f19b3a4aee0ff6ca8b5 (diff)
fix(terminal): restore keyboard reporting on detach (#2395)
refs #2393 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/terminal_modes.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/terminal_modes.rs b/src/terminal_modes.rs
index 8f0276e0..90ec512b 100644
--- a/src/terminal_modes.rs
+++ b/src/terminal_modes.rs
@@ -1,5 +1,7 @@
use std::io::{self, Write};
+#[cfg(not(windows))]
+use crossterm::event::{PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags};
#[cfg(any(not(windows), test))]
const DISABLE_HOST_MOUSE_REPORTING_SEQUENCE: &[u8] =
b"\x1b[?1006l\x1b[?1016l\x1b[?1015l\x1b[?1005l\x1b[?1003l\x1b[?1002l\x1b[?1000l";
@@ -24,8 +26,13 @@ pub(crate) fn set_host_kitty_keyboard_report_all<W: Write>(
if report_all_keys {
flags |= crossterm::event::KeyboardEnhancementFlags::REPORT_ALL_KEYS_AS_ESCAPE_CODES;
}
- write!(writer, "\x1b[={}u", flags.bits())?;
- writer.flush()
+ // Older iTerm2 releases clear the keyboard stack on SET, so a later pop
+ // cannot restore the host state. Replace only Herdr's top entry instead.
+ crossterm::execute!(
+ writer,
+ PopKeyboardEnhancementFlags,
+ PushKeyboardEnhancementFlags(flags)
+ )
}
#[cfg(windows)]
@@ -41,13 +48,13 @@ mod tests {
use super::*;
#[test]
- fn host_keyboard_report_all_only_changes_the_current_herdr_stack_entry() {
+ fn host_keyboard_report_all_replaces_the_current_herdr_stack_entry() {
let mut output = Vec::new();
set_host_kitty_keyboard_report_all(&mut output, true).unwrap();
set_host_kitty_keyboard_report_all(&mut output, false).unwrap();
- assert_eq!(output, b"\x1b[=15u\x1b[=7u");
+ assert_eq!(output, b"\x1b[<1u\x1b[>15u\x1b[<1u\x1b[>7u");
}
#[test]