@@ -54,7 +54,6 @@ fn terminal_quirk_from_env_eager() -> TerminalQuirks {
5454 // => since there's no way to know that we need to expect multiple responses
5555 // some of them are not consumed by us and end up on the user's screen :/
5656 Ok ( term) if term == "screen" || term. starts_with ( "screen." ) => Unsupported ,
57- Ok ( term) if term == "rxvt-unicode" || term. starts_with ( "rxvt-unicode-" ) => Urxvt ,
5857 Ok ( _) => None ,
5958 }
6059}
@@ -63,7 +62,6 @@ fn terminal_quirk_from_env_eager() -> TerminalQuirks {
6362pub ( crate ) enum TerminalQuirks {
6463 None ,
6564 Unsupported ,
66- Urxvt ,
6765}
6866
6967impl TerminalQuirks {
@@ -72,17 +70,19 @@ impl TerminalQuirks {
7270 }
7371
7472 pub ( crate ) fn string_terminator ( self ) -> & ' static [ u8 ] {
75- const ST : & [ u8 ] = b"\x1b \\ " ;
73+ // The currently released version of rxvt-unicode (urxvt) has a bug where it terminates the response with `ESC` instead of `ST` (`ESC \`).
74+ // This causes us to run into the timeout because we get stuck waiting for a `\` that never arrives.
75+ // Fixed by revision [1.600](http://cvs.schmorp.de/rxvt-unicode/src/command.C?revision=1.600&view=markup).
76+ // The bug can be worked around by sending a query with `BEL` which will result in a `BEL`-terminated response.
77+ //
78+ // Originally, we used `BEL` only for urxvt. However, after a discussion in delta [1],
79+ // I noticed that there are quite a few people who use urxvt with a different `TERM`
80+ // env var (e.g. `urxvt`, `xterm`, or even `screen`) [2].
81+ //
82+ // [1]: https://github.com/dandavison/delta/issues/1897
83+ // [2]: https://github.com/search?q=URxvt*termName&type=code
7684 const BEL : u8 = 0x07 ;
77-
78- if let TerminalQuirks :: Urxvt = self {
79- // The currently released version has a bug where it terminates the response with `ESC` instead of `ST`.
80- // Fixed by revision [1.600](http://cvs.schmorp.de/rxvt-unicode/src/command.C?revision=1.600&view=markup).
81- // The bug can be worked around by sending a query with `BEL` which will result in a `BEL`-terminated response.
82- & [ BEL ]
83- } else {
84- ST
85- }
85+ & [ BEL ]
8686 }
8787
8888 pub ( crate ) fn write_all ( self , w : & mut dyn Write , bytes : & [ u8 ] ) -> io:: Result < ( ) > {
0 commit comments