File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed
Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,20 @@ use std::sync::atomic::{AtomicBool, Ordering};
1818const TOKEN_STDIN : Token = Token ( 0 ) ;
1919const TOKEN_SOCKET : Token = Token ( 1 ) ;
2020const TOKEN_WAKE : Token = Token ( 2 ) ;
21- const DETACH_CLEANUP_SEQUENCES : & [ u8 ] =
22- b"\x1b [?1000l\x1b [?1002l\x1b [?1003l\x1b [?1006l\x1b [?2004l\x1b [?1049l\x1b [?25h" ;
21+ // Some interactive programs enable xterm/kitty keyboard enhancement modes.
22+ // Reset them on detach so the next shell prompt does not inherit CSI-u style
23+ // encodings such as Ctrl-D => `CSI 100;5u`.
24+ const DETACH_CLEANUP_SEQUENCES : & [ u8 ] = b"\
25+ \x1b [?1000l\
26+ \x1b [?1002l\
27+ \x1b [?1003l\
28+ \x1b [?1006l\
29+ \x1b [?2004l\
30+ \x1b [?1049l\
31+ \x1b [?25h\
32+ \x1b [>4n\
33+ \x1b [<u\
34+ \x1b [=0u";
2335
2436static SIGWINCH_RECEIVED : AtomicBool = AtomicBool :: new ( false ) ;
2537
@@ -317,3 +329,16 @@ pub fn run(
317329
318330 Ok ( exit_code)
319331}
332+
333+ #[ cfg( test) ]
334+ mod tests {
335+ use super :: DETACH_CLEANUP_SEQUENCES ;
336+
337+ #[ test]
338+ fn detach_cleanup_resets_keyboard_protocols ( ) {
339+ let cleanup = std:: str:: from_utf8 ( DETACH_CLEANUP_SEQUENCES ) . unwrap ( ) ;
340+ assert ! ( cleanup. contains( "\x1b [>4n" ) ) ;
341+ assert ! ( cleanup. contains( "\x1b [<u" ) ) ;
342+ assert ! ( cleanup. contains( "\x1b [=0u" ) ) ;
343+ }
344+ }
You can’t perform that action at this time.
0 commit comments