diff --git a/crates/nu-command/src/platform/ansi/ansi_.rs b/crates/nu-command/src/platform/ansi/ansi_.rs index 13c229a456..a7bb37036f 100644 --- a/crates/nu-command/src/platform/ansi/ansi_.rs +++ b/crates/nu-command/src/platform/ansi/ansi_.rs @@ -425,8 +425,6 @@ static CODE_LIST: Lazy> = Lazy::new(|| { vec![ AnsiCode { short_name: Some("grey89"), long_name: "xterm_grey89", code: Color::Fixed(254).prefix().to_string()}, AnsiCode { short_name: Some("grey93"), long_name: "xterm_grey93", code: Color::Fixed(255).prefix().to_string()}, - AnsiCode{ short_name: None, long_name: "reset", code: "\x1b[0m".to_owned()}, - // Attributes AnsiCode { short_name: Some("n"), long_name: "attr_normal", code: Color::Green.suffix().to_string()}, AnsiCode { short_name: Some("bo"), long_name: "attr_bold", code: Style::new().bold().prefix().to_string()}, @@ -437,6 +435,8 @@ static CODE_LIST: Lazy> = Lazy::new(|| { vec![ AnsiCode { short_name: Some("h"), long_name: "attr_hidden", code: Style::new().hidden().prefix().to_string()}, AnsiCode { short_name: Some("s"), long_name: "attr_strike", code: Style::new().strikethrough().prefix().to_string()}, + AnsiCode{ short_name: None, long_name: "reset", code: "\x1b[0m".to_owned()}, + // Reference for ansi codes https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797 // Another good reference http://ascii-table.com/ansi-escape-sequences.php @@ -842,15 +842,19 @@ fn generate_ansi_code_list( .map(move |(i, ansi_code)| { let name = Value::string(ansi_code.long_name, call_span); let short_name = Value::string(ansi_code.short_name.unwrap_or(""), call_span); - // The first 102 items in the ansi array are colors - let preview = if i < 389 { - Value::string(format!("{}NUSHELL\u{1b}[0m", &ansi_code.code), call_span) - } else { - Value::string("\u{1b}[0m", call_span) - }; let code = Value::string(ansi_code.code.replace('\u{1b}', "\\e"), call_span); let record = if use_ansi_coloring { + // The first 397 items in the ansi array are previewable + let preview = if i < 397 { + Value::string( + format!("\u{1b}[0m{}NUSHELL\u{1b}[0m", &ansi_code.code), + call_span, + ) + } else { + Value::string("\u{1b}[0m", call_span) + }; + record! { "name" => name, "preview" => preview,