Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Side-By-Side comparison adds extraneous escape #30

Open
3 tasks done
JamesWTruher opened this issue Feb 23, 2023 · 2 comments
Open
3 tasks done

Side-By-Side comparison adds extraneous escape #30

JamesWTruher opened this issue Feb 23, 2023 · 2 comments
Milestone

Comments

@JamesWTruher
Copy link
Contributor

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

$rightText = @("  This is other", "example text used!") -join [Environment]::NewLine
$leftText = @("This is some", "example text.") -join [Environment]::NewLine
compare-text $leftText $rightText -view side | out-string -str | %{$_.replace("`e","``e")}

Expected behavior

the escape sequence should be correct

Actual behavior

The output looks as follows:

`e[0m1 | `e[0mThis is `e[1;9;31msome`e[0m`e[0m `e[0m | `e[0;1;32m  `e[0mThis is `e[0;1;32mother`e…`e[0m
`e[0m`e[0m`e[1;9;31m`e[0m`e[0m`e[0m`e[0;1;32m`e[0m`e[0;1;32m`e[0m2 | `e[0mexample text`e[1;9;31m.`e[0m`e[0m | `e[0mexample text`e[0;1;32m…`e[0m

before the ellipsis of the first line of output there is an extraneous "`e" (or perhaps an escape sequence which is incomplete)

Error details

there is no error

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.0
PSEdition                      Core
GitCommitId                    7.3.0
OS                             Darwin 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:42:11 PST 2023; root:xnu-8792.81.3~2/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

0.4.0 preview2

Visuals

No response

@JamesWTruher
Copy link
Contributor Author

JamesWTruher commented Feb 23, 2023

it looks more like the truncation is not tracking whether it's in the middle of an escape sequence (which is quite tricky)

@SteveL-MSFT
Copy link
Member

Use PSStyle class to remove escape sequences to calculate length/width correctly

@SteveL-MSFT SteveL-MSFT added this to the 1.0 Consider milestone Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants