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

Enable VS Code's shell integration #1958

Merged
merged 1 commit into from
Nov 21, 2022

Conversation

andyleejordan
Copy link
Member

It seems to work, but needs more testing.

I don't particularly like copy/pasting https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.ps1 with modifications to embed it, but not sure what else to do here.

Resolves PowerShell/vscode-powershell#3901 along with PowerShell/vscode-powershell#4271.

@andyleejordan andyleejordan added Issue-Enhancement A feature request (enhancement). Area-Extension Terminal labels Nov 17, 2022
@andyleejordan
Copy link
Member Author

Per PowerShell/vscode-powershell#3901 (comment) we may also want a separate setting to enable/disable this just for the Extension Terminal.

@andyleejordan andyleejordan marked this pull request as ready for review November 18, 2022 22:07
@andyleejordan andyleejordan requested a review from a team November 18, 2022 22:07
@andyleejordan andyleejordan changed the title WIP: Enable VS Code's shell integration Enable VS Code's shell integration Nov 18, 2022
@andyleejordan
Copy link
Member Author

@Tyriar hey we got it! Though like I said, I really don't like my copy/paste method, but I'm unsure if anything else is better, we may just have to settle for it.

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 with one optional suggestion

It seems to work, but needs more testing.
@andyleejordan andyleejordan force-pushed the andschwa/enable-shell-integration branch from 07ffe63 to fb41949 Compare November 21, 2022 20:44
@andyleejordan andyleejordan enabled auto-merge (squash) November 21, 2022 21:00
@andyleejordan andyleejordan merged commit 5e9aeb2 into main Nov 21, 2022
@andyleejordan andyleejordan deleted the andschwa/enable-shell-integration branch November 21, 2022 21:01
@JustinGrote
Copy link
Collaborator

@andschwa exciting! Looking forward to testing this.

// https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.ps1
// with quotes escaped, `__VSCodeOriginalPSConsoleHostReadLine` removed (as it's done
// in our own ReadLine function), and `[Console]::Write` replaced with `Write-Host`.
// TODO: We can probably clean some of this up.
Copy link

Choose a reason for hiding this comment

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

Clean up PRs to the source are welcome 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to touch it as little as possible for now to make sure we don't break anything.

return;
}

# Disable shell integration when the language mode is restricted
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey guys, I know I'm late to the party but I was wondering what the risk of enabling this in Constrained Language mode would be? I run PowerShell in Constrained Language Mode in my web application and use xterm.js and would love to have proper terminal support.

Copy link

Choose a reason for hiding this comment

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

Certain things that we need don't work when not in this mode.

in my web application and use xterm.js and would love to have proper terminal support.

There's a bunch of code in vscode to handle shell integration, you wouldn't be able to just drop this script in an xterm.js frontend and have it work

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we control the host we could move a lot of these VT sequences to C# (e.g. just do Console.Write before invoking prompt).

But that would be more explicitly depending on the implementation detail of the script rather than copy pasting it, and as @Tyriar points out it wouldn't help the target scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Extension Terminal Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support New VS Code Shell Integration Feature
5 participants