mirror of
https://github.com/nushell/nushell.git
synced 2025-08-16 01:28:24 +02:00
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,6 @@ nu-utils = { path = "../nu-utils", version = "0.70.1" }
|
||||
|
||||
chrono = { version="0.4.21", features=["serde"] }
|
||||
sysinfo = "0.26.2"
|
||||
strip-ansi-escapes = "0.1.1"
|
||||
|
||||
[features]
|
||||
plugin = []
|
||||
|
@ -170,17 +170,11 @@ fn get_documentation(
|
||||
|
||||
long_desc.push('\n');
|
||||
|
||||
let stripped_string = if config.no_color {
|
||||
if let Ok(bytes) = strip_ansi_escapes::strip(&long_desc) {
|
||||
String::from_utf8_lossy(&bytes).to_string()
|
||||
} else {
|
||||
long_desc
|
||||
}
|
||||
if config.no_color {
|
||||
nu_utils::strip_ansi_string_likely(long_desc)
|
||||
} else {
|
||||
long_desc
|
||||
};
|
||||
|
||||
stripped_string
|
||||
}
|
||||
}
|
||||
|
||||
// document shape helps showing more useful information
|
||||
|
Reference in New Issue
Block a user