dahlbyk / posh-git

A PowerShell environment for Git
http://dahlbyk.github.io/posh-git/
MIT License
7.7k stars 801 forks source link

Setting BranchAheadStatusSymbol results in spurious `e[0m #911

Open rlipscombe opened 2 years ago

rlipscombe commented 2 years ago

System Details

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)

dahlbyk commented 2 years ago

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

rlipscombe commented 2 years ago

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)