diff --git a/src/utils.rs b/src/utils.rs index ff84961ccf..d232244810 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -47,7 +47,7 @@ pub fn truncate(s: &str, max_len: usize) -> String { /// ``` pub fn strip_ansi(text: &str) -> String { lazy_static::lazy_static! { - static ref ANSI_RE: Regex = Regex::new(r"\x1b\[[0-9;]*[a-zA-Z]").unwrap(); + static ref ANSI_RE: Regex = Regex::new(r"\x1b\[[0-9;:]*[a-zA-Z]").unwrap(); } ANSI_RE.replace_all(text, "").to_string() } @@ -369,6 +369,12 @@ mod tests { assert_eq!(strip_ansi(input), "Green normal Red"); } + #[test] + fn bugfix_issue_4_test_strip_ansi_colon_sgr() { + let input = "\x1b[38:2:255:0:0mRed\x1b[0m"; + assert_eq!(strip_ansi(input), "Red"); + } + #[test] fn test_execute_command_success() { let result = execute_command("echo", &["test"]);