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

Pass the path to shellIntegration.ps1 directly to the server #4959

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

andyleejordan
Copy link
Member

@andyleejordan andyleejordan commented Apr 3, 2024

The server can't use code --locate-shell-integration-path pwsh because it doesn't know if it's code or code-insiders etc. Even when given the direct path to the client's host process, it can't reliably use that API either. Mostly this is due to Windows using Code.cmd in the background (which is not Code.exe, the host process) but it's also slower anyway as it requires another launch of Node.js.

We'll have to rely on the path to the script not changing relative to vscode.env.appRoot, but at least that part is a public API.

Required by PowerShell/PowerShellEditorServices#2156.

@andyleejordan andyleejordan requested a review from a team April 3, 2024 16:54
@andyleejordan andyleejordan added the Issue-Enhancement A feature request (enhancement). label Apr 3, 2024
The server can't use `code --locate-shell-integration-path pwsh`
because it doesn't know if it's `code` or `code-insiders` etc.
Even when given the direct path to the client's host process, it can't
reliably use that API either. Mostly this is due to Windows using
`Code.cmd` in the background (which is not `Code.exe`, the host process)
but it's also slower anyway as it requires another launch of Node.js.

We'll have to rely on the path to the script not changing relative to
`vscode.env.appRoot`, but at least that part is a public API.
@andyleejordan andyleejordan changed the title Pass Code's executable path to PowerShell Editor Services Pass the path to shellIntegration.ps1 directly to the server Apr 3, 2024
// When Terminal Shell Integration is enabled, we pass the path to the script that the server should execute.
// Passing an empty string implies integration is disabled.
const shellIntegrationEnabled = vscode.workspace.getConfiguration("terminal.integrated.shellIntegration").get<boolean>("enabled");
const shellIntegrationScript = path.join(vscode.env.appRoot, "out", "vs", "workbench", "contrib", "terminal", "browser", "media", "shellIntegration.ps1");
Copy link
Member Author

Choose a reason for hiding this comment

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

@Tyriar I'm taking a hard dependency on this relative-to-app-root path. You all have too, but just internally as far as I can tell. Trust me, it was no good going down the road of passing process.argv0 and trying to use code --locate-blah-blah.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to know, chances of that path changing are very slim anyway

@andyleejordan andyleejordan enabled auto-merge April 3, 2024 19:43
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 added this pull request to the merge queue Apr 3, 2024
Merged via the queue into main with commit 431e236 Apr 3, 2024
6 checks passed
@andyleejordan andyleejordan deleted the shell-integration branch April 3, 2024 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement A feature request (enhancement).
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants