mirror of
https://github.com/nushell/nushell.git
synced 2025-07-07 10:01:26 +02:00
make cd
, cp
, ls
, mv
, open
and rm
automatically strip ansi codes (#6220)
* make `cd`, `cp`, `ls`, `mv`, `open` and `rm` automatically strip ansi escape code * fix nu-cli test * fix nu-cli test 2 * fix nu-cli test 3 * remove `include-ansi` arg * fix test
This commit is contained in:
@ -50,6 +50,20 @@ impl Command for Open {
|
||||
let ctrlc = engine_state.ctrlc.clone();
|
||||
let path = call.opt::<Spanned<String>>(engine_state, stack, 0)?;
|
||||
|
||||
let path = {
|
||||
if let Some(path_val) = path {
|
||||
Some(Spanned {
|
||||
item: match strip_ansi_escapes::strip(&path_val.item) {
|
||||
Ok(item) => String::from_utf8(item).unwrap_or(path_val.item),
|
||||
Err(_) => path_val.item,
|
||||
},
|
||||
span: path_val.span,
|
||||
})
|
||||
} else {
|
||||
path
|
||||
}
|
||||
};
|
||||
|
||||
let path = if let Some(path) = path {
|
||||
path
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user