@@ -147,7 +147,7 @@ export class SessionManager implements Middleware {
147
147
148
148
// The `exeNameOverride` is used by `restartSession` to override ANY other setting.
149
149
// We've made this function idempotent, so it can used to ensure the session has started.
150
- public async start ( exeNameOverride ?: string ) : Promise < void > {
150
+ public async start ( ) : Promise < void > {
151
151
switch ( this . sessionStatus ) {
152
152
case SessionStatus . NotStarted :
153
153
// Go ahead and start.
@@ -177,20 +177,16 @@ export class SessionManager implements Middleware {
177
177
break ;
178
178
}
179
179
180
+ // This status needs to be set immediately so the above check works
180
181
this . setSessionStatus ( "Starting..." , SessionStatus . Starting ) ;
182
+
181
183
this . startCancellationTokenSource = new vscode . CancellationTokenSource ( ) ;
182
184
const cancellationToken = this . startCancellationTokenSource . token ;
183
185
184
- if ( exeNameOverride != undefined ) {
185
- this . logger . writeVerbose ( `Starting with executable overriden to: ${ exeNameOverride } ` ) ;
186
- this . sessionSettings . powerShellDefaultVersion = exeNameOverride ;
187
- }
188
-
189
186
// Create a folder for the session files.
190
187
await vscode . workspace . fs . createDirectory ( this . sessionsFolder ) ;
191
188
192
189
// Migrate things.
193
- await this . promptPowerShellExeSettingsCleanup ( ) ;
194
190
await this . migrateWhitespaceAroundPipeSetting ( ) ;
195
191
196
192
// Find the PowerShell executable to use for the server.
@@ -205,6 +201,8 @@ export class SessionManager implements Middleware {
205
201
return ;
206
202
}
207
203
204
+ // Refresh the status with the found executable details.
205
+ this . refreshSessionStatus ( ) ;
208
206
this . logger . write ( `Starting '${ this . PowerShellExeDetails . displayName } ' at: ${ this . PowerShellExeDetails . exePath } ` ) ;
209
207
210
208
// Start the server.
@@ -274,7 +272,6 @@ export class SessionManager implements Middleware {
274
272
this . startCancellationTokenSource ?. dispose ( ) ;
275
273
this . startCancellationTokenSource = undefined ;
276
274
this . sessionDetails = undefined ;
277
- this . versionDetails = undefined ;
278
275
279
276
this . setSessionStatus ( "Not Started" , SessionStatus . NotStarted ) ;
280
277
}
@@ -286,7 +283,16 @@ export class SessionManager implements Middleware {
286
283
// Re-load the settings.
287
284
this . sessionSettings = getSettings ( ) ;
288
285
289
- await this . start ( exeNameOverride ) ;
286
+ if ( exeNameOverride ) {
287
+ // Reset the version and PowerShell details since we're launching a
288
+ // new executable.
289
+ this . logger . writeVerbose ( `Starting with executable overriden to: ${ exeNameOverride } ` ) ;
290
+ this . sessionSettings . powerShellDefaultVersion = exeNameOverride ;
291
+ this . versionDetails = undefined ;
292
+ this . PowerShellExeDetails = undefined ;
293
+ }
294
+
295
+ await this . start ( ) ;
290
296
}
291
297
292
298
public getSessionDetails ( ) : IEditorServicesSessionDetails | undefined {
@@ -432,38 +438,6 @@ export class SessionManager implements Middleware {
432
438
}
433
439
}
434
440
435
- // TODO: Remove this migration code.
436
- private async promptPowerShellExeSettingsCleanup ( ) : Promise < void > {
437
- if ( this . sessionSettings . powerShellExePath === "" ) {
438
- return ;
439
- }
440
-
441
- this . logger . writeWarning ( "Deprecated setting: powerShellExePath" ) ;
442
- let warningMessage = "The 'powerShell.powerShellExePath' setting is no longer used. " ;
443
- warningMessage += this . sessionSettings . powerShellDefaultVersion
444
- ? "We can automatically remove it for you."
445
- : "We can remove it from your settings and prompt you for which PowerShell you want to use." ;
446
-
447
- const choice = await vscode . window . showWarningMessage ( warningMessage , "Let's do it!" ) ;
448
-
449
- if ( choice === undefined ) {
450
- // They hit the 'x' to close the dialog.
451
- return ;
452
- }
453
-
454
- this . suppressRestartPrompt = true ;
455
- try {
456
- await changeSetting ( "powerShellExePath" , undefined , true , this . logger ) ;
457
- } finally {
458
- this . suppressRestartPrompt = false ;
459
- }
460
-
461
- // Show the session menu at the end if they don't have a PowerShellDefaultVersion.
462
- if ( this . sessionSettings . powerShellDefaultVersion === "" ) {
463
- await vscode . commands . executeCommand ( this . ShowSessionMenuCommandName ) ;
464
- }
465
- }
466
-
467
441
private async onConfigurationUpdated ( ) : Promise < void > {
468
442
const settings = getSettings ( ) ;
469
443
this . logger . updateLogLevel ( settings . developer . editorServicesLogLevel ) ;
@@ -524,7 +498,6 @@ export class SessionManager implements Middleware {
524
498
break ;
525
499
}
526
500
}
527
-
528
501
}
529
502
foundPowerShell = defaultPowerShell ?? await powershellExeFinder . getFirstAvailablePowerShellInstallation ( ) ;
530
503
if ( wantedName !== "" && defaultPowerShell === undefined && foundPowerShell !== undefined ) {
@@ -846,9 +819,12 @@ Type 'help' to get help.
846
819
const semver = new SemVer ( this . versionDetails . version ) ;
847
820
this . languageStatusItem . text += ` ${ semver . major } .${ semver . minor } ` ;
848
821
this . languageStatusItem . detail += ` ${ this . versionDetails . commit } (${ this . versionDetails . architecture . toLowerCase ( ) } )` ;
849
- } else if ( this . PowerShellExeDetails ?. displayName ) { // In case it didn 't start .
822
+ } else if ( this . PowerShellExeDetails ?. displayName ) { // When it hasn 't started yet .
850
823
this . languageStatusItem . text += ` ${ this . PowerShellExeDetails . displayName } ` ;
851
824
this . languageStatusItem . detail += ` at '${ this . PowerShellExeDetails . exePath } '` ;
825
+ } else if ( this . sessionSettings . powerShellDefaultVersion ) { // When it hasn't been found yet.
826
+ this . languageStatusItem . text += ` ${ this . sessionSettings . powerShellDefaultVersion } ` ;
827
+ this . languageStatusItem . detail = `Looking for '${ this . sessionSettings . powerShellDefaultVersion } '...` ;
852
828
}
853
829
854
830
if ( detail ) {
@@ -877,6 +853,11 @@ Type 'help' to get help.
877
853
}
878
854
}
879
855
856
+ // Refreshes the Language Status Item details with ehe same status.
857
+ private refreshSessionStatus ( ) : void {
858
+ this . setSessionStatus ( "" , this . sessionStatus ) ;
859
+ }
860
+
880
861
private setSessionRunningStatus ( ) : void {
881
862
this . setSessionStatus ( "" , SessionStatus . Running ) ;
882
863
}
0 commit comments