TextUtility icon indicating copy to clipboard operation
TextUtility copied to clipboard

Side-By-Side comparison adds extraneous escape

Open JamesWTruher opened this issue 2 years ago • 2 comments

Prerequisites

  • [X] Write a descriptive title.
  • [X] Make sure you are able to repro it on the latest version
  • [X] 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 avatar Feb 23 '23 00:02 JamesWTruher

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

JamesWTruher avatar Feb 23 '23 20:02 JamesWTruher

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

SteveL-MSFT avatar Jul 25 '23 23:07 SteveL-MSFT