mirror of
https://github.com/nushell/nushell.git
synced 2025-05-28 14:07:08 +02:00
Fixes clip copy
stripping control characters when de-ansifying (#15428)
Fixes #15414 by changing the method used to de-ansi-fy the input. Control characters will now be kept when using `clip copy`, but ANSI escape codes will be removed (when not using `--ansi (-a)`)
This commit is contained in:
parent
5fe97b8d59
commit
49d86855ce
@ -11,6 +11,9 @@ export def copy [
|
||||
--ansi (-a) # Copy ansi formatting
|
||||
]: any -> nothing {
|
||||
let input = $in | collect
|
||||
if not $ansi {
|
||||
$env.config.use_ansi_coloring = false
|
||||
}
|
||||
let text = match ($input | describe -d | get type) {
|
||||
$type if $type in [ table, record, list ] => {
|
||||
$input | table -e
|
||||
@ -18,18 +21,7 @@ export def copy [
|
||||
_ => {$input}
|
||||
}
|
||||
|
||||
let do_strip_ansi = match $ansi {
|
||||
true => {{||}}
|
||||
false => {{|| ansi strip }}
|
||||
}
|
||||
|
||||
let output = (
|
||||
$text
|
||||
| do $do_strip_ansi
|
||||
| encode base64
|
||||
)
|
||||
|
||||
print -n $'(ansi osc)52;c;($output)(ansi st)'
|
||||
print -n $'(ansi osc)52;c;($text | encode base64)(ansi st)'
|
||||
}
|
||||
|
||||
# Paste contents of system clipboard
|
||||
|
Loading…
x
Reference in New Issue
Block a user