fix(core): skip vt100 parsing if tui disabled (#31010)

This commit is contained in:
Craigory Coppola 2025-05-02 14:35:03 -04:00 committed by GitHub
parent 7059d6f17b
commit 6e1f304898
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -109,17 +109,21 @@ impl PseudoTerminal {
let quiet = quiet_clone.load(Ordering::Relaxed);
trace!("Quiet: {}", quiet);
debug!("Read {} bytes", len);
if is_within_nx_tui {
if let Ok(mut parser) = parser_clone.write() {
if is_within_nx_tui {
trace!("Processing data via vt100 for use in tui");
parser.process(&buf[..len]);
}
}
}
if !quiet {
let mut logged_interrupted_error = false;
let mut content = String::from_utf8_lossy(&buf[0..len]).to_string();
if content.contains("\x1B[6n") {
trace!(
"Prevented terminal escape sequence ESC[6n from being printed."
);
trace!("Prevented terminal escape sequence ESC[6n from being printed.");
content = content.replace("\x1B[6n", "");
}
@ -144,7 +148,6 @@ impl PseudoTerminal {
}
}
let _ = stdout.flush();
}
} else {
debug!("Failed to lock parser");
}
@ -211,10 +214,13 @@ impl PseudoTerminal {
let command_info = format!("> {}\n\n\r", command_label.unwrap_or(command));
self.stdout_tx.send(command_info.clone()).ok();
if self.is_within_nx_tui {
self.parser
.write()
.expect("Failed to acquire parser write lock")
.process(command_info.as_bytes());
}
trace!("Running {}", command_clone);
let mut child = pair.slave.spawn_command(cmd)?;
self.running.store(true, Ordering::SeqCst);