Disable CSI u in Jetbrains terminals

Note: This may not be sent in WSL.

Fixes #10829
This commit is contained in:
Fabian Boehm 2024-11-06 18:51:31 +01:00
parent 4b24fe7daf
commit bfc68345c9

View file

@ -433,6 +433,7 @@ static TERMINAL_PROTOCOLS: AtomicBool = AtomicBool::new(false);
static IS_TMUX: RelaxedAtomicBool = RelaxedAtomicBool::new(false);
pub static IN_MIDNIGHT_COMMANDER_PRE_CSI_U: RelaxedAtomicBool = RelaxedAtomicBool::new(false);
static IN_ITERM_PRE_CSI_U: RelaxedAtomicBool = RelaxedAtomicBool::new(false);
static IN_JETBRAINS: RelaxedAtomicBool = RelaxedAtomicBool::new(false);
pub fn terminal_protocol_hacks() {
use std::env::var_os;
@ -447,6 +448,10 @@ pub fn terminal_protocol_hacks() {
version < (3, 5, 6)
}),
);
IN_JETBRAINS.store(
var_os("TERMINAL_EMULATOR")
.is_some_and(|term| term.as_os_str().as_bytes() == b"JetBrains-JediTerm"),
);
}
fn parse_version(version: &wstr) -> Option<(i64, i64, i64)> {
@ -477,6 +482,9 @@ pub fn terminal_protocols_enable_ifn() {
"\x1b[?2004h"
} else if IN_ITERM_PRE_CSI_U.load() {
concat!("\x1b[?2004h", "\x1b[>4;1m", "\x1b[>5u", "\x1b=",)
} else if IN_JETBRAINS.load() {
// Jetbrains IDE terminals vomit CSI u
concat!("\x1b[?2004h", "\x1b[>4;1m", "\x1b=",)
} else {
concat!(
"\x1b[?2004h", // Bracketed paste
@ -499,6 +507,8 @@ pub(crate) fn terminal_protocols_disable_ifn() {
}
let sequences = if IN_ITERM_PRE_CSI_U.load() {
concat!("\x1b[?2004l", "\x1b[>4;0m", "\x1b[<1u", "\x1b>",)
} else if IN_JETBRAINS.load() {
concat!("\x1b[?2004l", "\x1b[>4;0m", "\x1b>",)
} else {
concat!(
"\x1b[?2004l", // Bracketed paste