@@ -103,8 +103,10 @@ export class SessionManager implements Middleware {
103
103
this . languageClientConsumers = languageClientConsumers ;
104
104
}
105
105
106
- public start ( exeNameOverride ?: string ) {
106
+ public async start ( exeNameOverride ?: string ) {
107
+ await Settings . validateCwdSetting ( ) ;
107
108
this . sessionSettings = Settings . load ( ) ;
109
+
108
110
if ( exeNameOverride ) {
109
111
this . sessionSettings . powerShellDefaultVersion = exeNameOverride ;
110
112
}
@@ -240,9 +242,9 @@ export class SessionManager implements Middleware {
240
242
this . sessionStatus = SessionStatus . NotStarted ;
241
243
}
242
244
243
- public restartSession ( exeNameOverride ?: string ) {
245
+ public async restartSession ( exeNameOverride ?: string ) {
244
246
this . stop ( ) ;
245
- this . start ( exeNameOverride ) ;
247
+ await this . start ( exeNameOverride ) ;
246
248
}
247
249
248
250
public getSessionDetails ( ) : utils . IEditorServicesSessionDetails {
@@ -387,14 +389,16 @@ export class SessionManager implements Middleware {
387
389
}
388
390
}
389
391
390
- private onConfigurationUpdated ( ) {
392
+ private async onConfigurationUpdated ( ) {
391
393
const settings = Settings . load ( ) ;
392
394
393
395
this . focusConsoleOnExecute = settings . integratedConsole . focusConsoleOnExecute ;
394
396
395
397
// Detect any setting changes that would affect the session
396
398
if ( ! this . suppressRestartPrompt &&
397
- ( settings . powerShellDefaultVersion . toLowerCase ( ) !==
399
+ ( settings . cwd . toLowerCase ( ) !==
400
+ this . sessionSettings . cwd . toLowerCase ( ) ||
401
+ settings . powerShellDefaultVersion . toLowerCase ( ) !==
398
402
this . sessionSettings . powerShellDefaultVersion . toLowerCase ( ) ||
399
403
settings . developer . editorServicesLogLevel . toLowerCase ( ) !==
400
404
this . sessionSettings . developer . editorServicesLogLevel . toLowerCase ( ) ||
@@ -403,14 +407,13 @@ export class SessionManager implements Middleware {
403
407
settings . integratedConsole . useLegacyReadLine !==
404
408
this . sessionSettings . integratedConsole . useLegacyReadLine ) ) {
405
409
406
- vscode . window . showInformationMessage (
410
+ const response : string = await vscode . window . showInformationMessage (
407
411
"The PowerShell runtime configuration has changed, would you like to start a new session?" ,
408
- "Yes" , "No" )
409
- . then ( ( response ) => {
412
+ "Yes" , "No" ) ;
413
+
410
414
if ( response === "Yes" ) {
411
- this . restartSession ( ) ;
415
+ await this . restartSession ( ) ;
412
416
}
413
- } ) ;
414
417
}
415
418
}
416
419
@@ -433,7 +436,7 @@ export class SessionManager implements Middleware {
433
436
this . registeredCommands = [
434
437
vscode . commands . registerCommand ( "PowerShell.RestartSession" , ( ) => { this . restartSession ( ) ; } ) ,
435
438
vscode . commands . registerCommand ( this . ShowSessionMenuCommandName , ( ) => { this . showSessionMenu ( ) ; } ) ,
436
- vscode . workspace . onDidChangeConfiguration ( ( ) => this . onConfigurationUpdated ( ) ) ,
439
+ vscode . workspace . onDidChangeConfiguration ( async ( ) => { await this . onConfigurationUpdated ( ) ; } ) ,
437
440
vscode . commands . registerCommand (
438
441
"PowerShell.ShowSessionConsole" , ( isExecute ?: boolean ) => { this . showSessionConsole ( isExecute ) ; } ) ,
439
442
] ;
@@ -457,10 +460,10 @@ export class SessionManager implements Middleware {
457
460
this . sessionSettings ) ;
458
461
459
462
this . languageServerProcess . onExited (
460
- ( ) => {
463
+ async ( ) => {
461
464
if ( this . sessionStatus === SessionStatus . Running ) {
462
465
this . setSessionStatus ( "Session Exited" , SessionStatus . Failed ) ;
463
- this . promptForRestart ( ) ;
466
+ await this . promptForRestart ( ) ;
464
467
}
465
468
} ) ;
466
469
@@ -503,11 +506,14 @@ export class SessionManager implements Middleware {
503
506
} ) ;
504
507
}
505
508
506
- private promptForRestart ( ) {
507
- vscode . window . showErrorMessage (
509
+ private async promptForRestart ( ) {
510
+ const response : string = await vscode . window . showErrorMessage (
508
511
"The PowerShell Integrated Console (PSIC) has stopped, would you like to restart it? (IntelliSense will not work unless the PSIC is active and unblocked.)" ,
509
- "Yes" , "No" )
510
- . then ( ( answer ) => { if ( answer === "Yes" ) { this . restartSession ( ) ; } } ) ;
512
+ "Yes" , "No" ) ;
513
+
514
+ if ( response === "Yes" ) {
515
+ await this . restartSession ( ) ;
516
+ }
511
517
}
512
518
513
519
private startLanguageClient ( sessionDetails : utils . IEditorServicesSessionDetails ) {
@@ -756,7 +762,7 @@ export class SessionManager implements Middleware {
756
762
// rather than pull from the settings. The issue we prevent here is when a
757
763
// workspace setting is defined which gets priority over user settings which
758
764
// is what the change above sets.
759
- this . restartSession ( exePath . displayName ) ;
765
+ await this . restartSession ( exePath . displayName ) ;
760
766
}
761
767
762
768
private showSessionConsole ( isExecute ?: boolean ) {
@@ -817,10 +823,10 @@ export class SessionManager implements Middleware {
817
823
818
824
new SessionMenuItem (
819
825
"Restart Current Session" ,
820
- ( ) => {
826
+ async ( ) => {
821
827
// We pass in the display name so we guarantee that the session
822
828
// will be the same PowerShell.
823
- this . restartSession ( this . PowerShellExeDetails . displayName ) ;
829
+ await this . restartSession ( this . PowerShellExeDetails . displayName ) ;
824
830
} ) ,
825
831
826
832
new SessionMenuItem (
0 commit comments