@@ -103,8 +103,10 @@ export class SessionManager implements Middleware {
103103 this . languageClientConsumers = languageClientConsumers ;
104104 }
105105
106- public start ( exeNameOverride ?: string ) {
106+ public async start ( exeNameOverride ?: string ) {
107+ await Settings . validateCwdSetting ( ) ;
107108 this . sessionSettings = Settings . load ( ) ;
109+
108110 if ( exeNameOverride ) {
109111 this . sessionSettings . powerShellDefaultVersion = exeNameOverride ;
110112 }
@@ -240,9 +242,9 @@ export class SessionManager implements Middleware {
240242 this . sessionStatus = SessionStatus . NotStarted ;
241243 }
242244
243- public restartSession ( exeNameOverride ?: string ) {
245+ public async restartSession ( exeNameOverride ?: string ) {
244246 this . stop ( ) ;
245- this . start ( exeNameOverride ) ;
247+ await this . start ( exeNameOverride ) ;
246248 }
247249
248250 public getSessionDetails ( ) : utils . IEditorServicesSessionDetails {
@@ -387,14 +389,16 @@ export class SessionManager implements Middleware {
387389 }
388390 }
389391
390- private onConfigurationUpdated ( ) {
392+ private async onConfigurationUpdated ( ) {
391393 const settings = Settings . load ( ) ;
392394
393395 this . focusConsoleOnExecute = settings . integratedConsole . focusConsoleOnExecute ;
394396
395397 // Detect any setting changes that would affect the session
396398 if ( ! this . suppressRestartPrompt &&
397- ( settings . powerShellDefaultVersion . toLowerCase ( ) !==
399+ ( settings . cwd . toLowerCase ( ) !==
400+ this . sessionSettings . cwd . toLowerCase ( ) ||
401+ settings . powerShellDefaultVersion . toLowerCase ( ) !==
398402 this . sessionSettings . powerShellDefaultVersion . toLowerCase ( ) ||
399403 settings . developer . editorServicesLogLevel . toLowerCase ( ) !==
400404 this . sessionSettings . developer . editorServicesLogLevel . toLowerCase ( ) ||
@@ -403,14 +407,13 @@ export class SessionManager implements Middleware {
403407 settings . integratedConsole . useLegacyReadLine !==
404408 this . sessionSettings . integratedConsole . useLegacyReadLine ) ) {
405409
406- vscode . window . showInformationMessage (
410+ const response : string = await vscode . window . showInformationMessage (
407411 "The PowerShell runtime configuration has changed, would you like to start a new session?" ,
408- "Yes" , "No" )
409- . then ( ( response ) => {
412+ "Yes" , "No" ) ;
413+
410414 if ( response === "Yes" ) {
411- this . restartSession ( ) ;
415+ await this . restartSession ( ) ;
412416 }
413- } ) ;
414417 }
415418 }
416419
@@ -433,7 +436,7 @@ export class SessionManager implements Middleware {
433436 this . registeredCommands = [
434437 vscode . commands . registerCommand ( "PowerShell.RestartSession" , ( ) => { this . restartSession ( ) ; } ) ,
435438 vscode . commands . registerCommand ( this . ShowSessionMenuCommandName , ( ) => { this . showSessionMenu ( ) ; } ) ,
436- vscode . workspace . onDidChangeConfiguration ( ( ) => this . onConfigurationUpdated ( ) ) ,
439+ vscode . workspace . onDidChangeConfiguration ( async ( ) => { await this . onConfigurationUpdated ( ) ; } ) ,
437440 vscode . commands . registerCommand (
438441 "PowerShell.ShowSessionConsole" , ( isExecute ?: boolean ) => { this . showSessionConsole ( isExecute ) ; } ) ,
439442 ] ;
@@ -457,10 +460,10 @@ export class SessionManager implements Middleware {
457460 this . sessionSettings ) ;
458461
459462 this . languageServerProcess . onExited (
460- ( ) => {
463+ async ( ) => {
461464 if ( this . sessionStatus === SessionStatus . Running ) {
462465 this . setSessionStatus ( "Session Exited" , SessionStatus . Failed ) ;
463- this . promptForRestart ( ) ;
466+ await this . promptForRestart ( ) ;
464467 }
465468 } ) ;
466469
@@ -503,11 +506,14 @@ export class SessionManager implements Middleware {
503506 } ) ;
504507 }
505508
506- private promptForRestart ( ) {
507- vscode . window . showErrorMessage (
509+ private async promptForRestart ( ) {
510+ const response : string = await vscode . window . showErrorMessage (
508511 "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+ }
511517 }
512518
513519 private startLanguageClient ( sessionDetails : utils . IEditorServicesSessionDetails ) {
@@ -756,7 +762,7 @@ export class SessionManager implements Middleware {
756762 // rather than pull from the settings. The issue we prevent here is when a
757763 // workspace setting is defined which gets priority over user settings which
758764 // is what the change above sets.
759- this . restartSession ( exePath . displayName ) ;
765+ await this . restartSession ( exePath . displayName ) ;
760766 }
761767
762768 private showSessionConsole ( isExecute ?: boolean ) {
@@ -817,10 +823,10 @@ export class SessionManager implements Middleware {
817823
818824 new SessionMenuItem (
819825 "Restart Current Session" ,
820- ( ) => {
826+ async ( ) => {
821827 // We pass in the display name so we guarantee that the session
822828 // will be the same PowerShell.
823- this . restartSession ( this . PowerShellExeDetails . displayName ) ;
829+ await this . restartSession ( this . PowerShellExeDetails . displayName ) ;
824830 } ) ,
825831
826832 new SessionMenuItem (
0 commit comments