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

Replace backtick-e with $([char]0x1b) #1961

Merged
merged 1 commit into from
Nov 23, 2022
Merged

Conversation

andyleejordan
Copy link
Member

By replacing backtick-e with $([char]0x1b), we allow shell integration to work with Windows PowerShell, as the only problem seemed to be use of backtick-e, which was an escape character added only to PowerShell Core, but the [char] equivalent works fine.

Same change as proposed upstream in microsoft/vscode#167023, resolves PowerShell/vscode-powershell#4279.

This allows shell integration to work with Windows PowerShell, as the
only problem seemed to be use of `e, which was an escape character added
only to PowerShell Core, but the `[char]` equivalent works fine.
@andyleejordan
Copy link
Member Author

Thanks @SeeminglyScience for the spot!

Copy link
Collaborator

@SeeminglyScience SeeminglyScience left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@andyleejordan andyleejordan enabled auto-merge (squash) November 23, 2022 23:27
@andyleejordan andyleejordan merged commit ab8bfa3 into main Nov 23, 2022
@andyleejordan andyleejordan deleted the andschwa/escape-char branch November 23, 2022 23:36
@Hrxn
Copy link

Hrxn commented Nov 30, 2022

Do I get this right, this is only a change for the sake of backward compatibility?

@msftrncs
Copy link

@Hrxn, Not necessarily backward compatible, more of a cross platform compatibility. Windows PowerShell is a still active currently supported platform. Consider that PowerShell Core is an enhanced platform, rather than a 'newer' version.

@SeeminglyScience
Copy link
Collaborator

Do I get this right, this is only a change for the sake of backward compatibility?

That's correct, the syntax `e only works in newer versions of PowerShell.

@Hrxn, Not necessarily backward compatible, more of a cross platform compatibility. Windows PowerShell is a still active currently supported platform. Consider that PowerShell Core is an enhanced platform, rather than a 'newer' version.

Windows PowerShell receives primarily only security updates. PowerShell 7 is definitely considered a newer version.

@Hrxn
Copy link

Hrxn commented Nov 30, 2022

Thank you for this explanation, appreciate it.
What I've always wondered, is there also some kind of performance difference between using
"$([char]0x1b)<ANSI_Esc_Sequence>" and "backtick-e<ANSI_Esc_Sequence>" ?

I've done some tests here on my machine with Measure-Command, but I could not find any conclusive result somehow yet.. 🤷‍♂️

@SeeminglyScience
Copy link
Collaborator

Technically `e will be faster as it'll be emitted by the compiler as a constant. Not enough to really matter though, use `e where you don't need to support 5.1 since it's easier to read. Otherwise don't stress it

@Hrxn
Copy link

Hrxn commented Dec 1, 2022

Thanks, glad that I finally found an answer for what has been a pretty longstanding question about powershell for me, to be honest.. 😉
Will use `e from now on, because I don't need/want to support 5.1

@SeeminglyScience
Copy link
Collaborator

Thanks, glad that I finally found an answer for what has been a pretty longstanding question about powershell for me, to be honest.. 😉 Will use `e from now on, because I don't need/want to support 5.1

If you aren't already there, check out the PowerShell Discord server. Plenty of folks hanging out ready to answer fun questions like that 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v2022.11.1-preview butchers terminal prompt using WinPS 5.1
4 participants