@@ -28,6 +28,7 @@ export class PowerShellProcess {
28
28
public exePath : string ,
29
29
private bundledModulesPath : string ,
30
30
private isTemp : boolean ,
31
+ private shellIntegrationEnabled : boolean ,
31
32
private logger : ILogger ,
32
33
private startPsesArgs : string ,
33
34
private sessionFilePath : vscode . Uri ,
@@ -99,12 +100,27 @@ export class PowerShellProcess {
99
100
// Make sure no old session file exists
100
101
await this . deleteSessionFile ( this . sessionFilePath ) ;
101
102
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
+
102
117
// Launch PowerShell in the integrated terminal
103
118
const terminalOptions : vscode . TerminalOptions = {
104
119
name : this . isTemp ? `${ PowerShellProcess . title } (TEMP)` : PowerShellProcess . title ,
105
120
shellPath : this . exePath ,
106
121
shellArgs : powerShellArgs ,
107
122
cwd : await validateCwdSetting ( this . logger ) ,
123
+ env : envMixin ,
108
124
iconPath : new vscode . ThemeIcon ( "terminal-powershell" ) ,
109
125
isTransient : true ,
110
126
hideFromUser : this . sessionSettings . integratedConsole . startInBackground ,
0 commit comments