@@ -28,6 +28,7 @@ export class PowerShellProcess {
2828 public exePath : string ,
2929 private bundledModulesPath : string ,
3030 private isTemp : boolean ,
31+ private shellIntegrationEnabled : boolean ,
3132 private logger : ILogger ,
3233 private startPsesArgs : string ,
3334 private sessionFilePath : vscode . Uri ,
@@ -99,12 +100,27 @@ export class PowerShellProcess {
99100 // Make sure no old session file exists
100101 await this . deleteSessionFile ( this . sessionFilePath ) ;
101102
103+ // When VS Code shell integration is enabled, the script expects certain
104+ // variables to be added to the environment.
105+ let envMixin = undefined ;
106+ if ( this . shellIntegrationEnabled ) {
107+ envMixin = {
108+ "VSCODE_INJECTION" : "1" ,
109+ // There is no great way to check if we are running stable VS
110+ // Code. Since this is used to disable experimental features, we
111+ // default to stable unless we're definitely running Insiders.
112+ "VSCODE_STABLE" : vscode . env . appName . includes ( "Insiders" ) ? "0" : "1" ,
113+ // Maybe one day we can set VSCODE_NONCE...
114+ } ;
115+ }
116+
102117 // Launch PowerShell in the integrated terminal
103118 const terminalOptions : vscode . TerminalOptions = {
104119 name : this . isTemp ? `${ PowerShellProcess . title } (TEMP)` : PowerShellProcess . title ,
105120 shellPath : this . exePath ,
106121 shellArgs : powerShellArgs ,
107122 cwd : await validateCwdSetting ( this . logger ) ,
123+ env : envMixin ,
108124 iconPath : new vscode . ThemeIcon ( "terminal-powershell" ) ,
109125 isTransient : true ,
110126 hideFromUser : this . sessionSettings . integratedConsole . startInBackground ,
0 commit comments