forked from extern/nushell
Refactor ansi stripping into nu-utils
functions (#6966)
Allows use of slightly optimized variants that check if they have to use the heavier vte parser. Tries to avoid unnnecessary allocations. Initial performance characteristics proven out in #4378. Also reduces boilerplate with right-ward drift.
This commit is contained in:
committed by
GitHub
parent
b9195c2668
commit
2c4048eb43
@ -15,7 +15,7 @@ path = "src/main.rs"
|
||||
[dependencies]
|
||||
nu-ansi-term = "0.46.0"
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.70.1" }
|
||||
strip-ansi-escapes = "0.1.1"
|
||||
nu-utils = { path = "../nu-utils", version = "0.70.1" }
|
||||
atty = "0.2.14"
|
||||
tabled = { version = "0.10.0", features = ["color"], default-features = false }
|
||||
json_to_table = { version = "0.2.0", features = ["color"] }
|
||||
|
@ -181,10 +181,7 @@ fn print_table(table: tabled::Table<Data>, config: &Config) -> String {
|
||||
// the atty is for when people do ls from vim, there should be no coloring there
|
||||
if !config.use_ansi_coloring || !atty::is(atty::Stream::Stdout) {
|
||||
// Draw the table without ansi colors
|
||||
match strip_ansi_escapes::strip(&output) {
|
||||
Ok(bytes) => String::from_utf8_lossy(&bytes).to_string(),
|
||||
Err(_) => output, // we did our best; so return at least something
|
||||
}
|
||||
nu_utils::strip_ansi_string_likely(output)
|
||||
} else {
|
||||
// Draw the table with ansi colors
|
||||
output
|
||||
|
Reference in New Issue
Block a user