@@ -367,15 +367,25 @@ impl<'a> Printer for InteractivePrinter<'a> {
367 match chunk {
367 match chunk {
368 // ANSI escape passthrough.
368 // ANSI escape passthrough.
369 (text, true) => {
369 (text, true) => {
370+ let is_ansi_csi = text.chars().skip(1).nth(0).map_or(false, |c|c == '[');
370− if text.chars().last().map_or(false, |c| c == 'm') {
372+ if is_ansi_csi && text.chars().last().map_or(false, |c| c == 'm') {
373+ // It's an ANSI SGR sequence.
374+ // We should be mostly safe to just append these together.
371 ansi_prefix.push_str(text);
375 ansi_prefix.push_str(text);
372 if text == "\x1B[0m" {
376 if text == "\x1B[0m" {
373 self.ansi_prefix_sgr = "\x1B[0m".to_owned();
377 self.ansi_prefix_sgr = "\x1B[0m".to_owned();
375 self.ansi_prefix_sgr.push_str(text);
379 self.ansi_prefix_sgr.push_str(text);
377− } else {
381+ } else if is_ansi_csi {
382+ // It's a regular CSI sequence.
383+ // We should be mostly safe to just append these together.
378 ansi_prefix.push_str(text);
384 ansi_prefix.push_str(text);
386+ // It's probably a VT100 code.
387+ // Passing it through is the safest bet.
388+ write!(handle, "{}", text)?;