Skip to content

Commit 7703924

Browse files
committed
Pass the path to shellIntegration.ps1 directly to the server
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.
1 parent 1f62851 commit 7703924

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/session.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@ export class SessionManager implements Middleware {
610610
});
611611
};
612612

613+
// When Terminal Shell Integration is enabled, we pass the path to the script that the server should execute.
614+
// Passing an empty string implies integration is disabled.
615+
const shellIntegrationEnabled = vscode.workspace.getConfiguration("terminal.integrated.shellIntegration").get<boolean>("enabled");
616+
const shellIntegrationScript = path.join(vscode.env.appRoot, "out", "vs", "workbench", "contrib", "terminal", "browser", "media", "shellIntegration.ps1");
617+
613618
const clientOptions: LanguageClientOptions = {
614619
documentSelector: this.documentSelector,
615620
synchronize: {
@@ -622,7 +627,7 @@ export class SessionManager implements Middleware {
622627
initializationOptions: {
623628
enableProfileLoading: this.sessionSettings.enableProfileLoading,
624629
initialWorkingDirectory: await validateCwdSetting(this.logger),
625-
shellIntegrationEnabled: vscode.workspace.getConfiguration("terminal.integrated.shellIntegration").get<boolean>("enabled"),
630+
shellIntegrationScript: shellIntegrationEnabled ? shellIntegrationScript : "",
626631
},
627632
errorHandler: {
628633
// Override the default error handler to prevent it from

0 commit comments

Comments
 (0)