posh-git icon indicating copy to clipboard operation
posh-git copied to clipboard

Setting BranchAheadStatusSymbol results in spurious `e[0m

Open rlipscombe opened this issue 2 years ago • 2 comments

System Details

  • posh-git version/path: 1.1.0 ~\Documents\PowerShell\Modules\posh-git\1.1.0
  • PowerShell version: 7.2.4
  • git version 2.27.0.windows.1
  • OS: Microsoft Windows NT 10.0.22621.0

Issue Description

When I set $GitPromptSettings.BranchAheadStatusSymbol, a spurious `e[0m is added to the end:

C:\Users\roger> $GitPromptSettings
...
BranchAheadStatusSymbol                : Text: "↑",  ANSI: "`e[92m↑`e[39m"
...

C:\Users\roger> $GitPromptSettings.BranchAheadStatusSymbol = "`e[92m↑`e[39m"
C:\Users\roger> $GitPromptSettings
...
BranchAheadStatusSymbol                : Text: "↑", ANSI: "`e[92m↑`e[39m`e[0m"
...

Any idea where this is coming from? ~~It doesn't happen when setting (e.g.) BeforeStatus.~~ (it does)

rlipscombe avatar Jun 25 '22 18:06 rlipscombe

I see the same behavior, but it's not immediately obvious why. @rkeithhill may have an idea?

dahlbyk avatar Jun 27 '22 14:06 dahlbyk

I had to work around it with the following:

# Work around the fact that PoshGitTextSpan isn't accessible.
$pgts = $GitPromptSettings.BeforeStatus.GetType()
$GitPromptSettings.BeforeStatus = $pgts::new('[', 0xEEEEEC)

rlipscombe avatar Jun 27 '22 19:06 rlipscombe