@@ -44,7 +44,6 @@ export enum RunspaceType {
4444export interface IEditorServicesSessionDetails {
4545 status : string ;
4646 reason : string ;
47- detail : string ;
4847 powerShellVersion : string ;
4948 channel : string ;
5049 languageServicePort : number ;
@@ -430,7 +429,7 @@ export class SessionManager implements Middleware {
430429
431430 private async startPowerShell ( ) : Promise < PowerShellProcess | undefined > {
432431 if ( this . PowerShellExeDetails === undefined ) {
433- this . setSessionFailure ( "Unable to find PowerShell. " ) ;
432+ void this . setSessionFailedGetPowerShell ( "Unable to find PowerShell, try installing it? " ) ;
434433 return ;
435434 }
436435
@@ -458,9 +457,6 @@ export class SessionManager implements Middleware {
458457 try {
459458 this . sessionDetails = await languageServerProcess . start ( "EditorServices" ) ;
460459 } catch ( err ) {
461- // We should kill the process in case it's stuck.
462- void languageServerProcess . dispose ( ) ;
463-
464460 // PowerShell never started, probably a bad version!
465461 const version = await languageServerProcess . getVersionCli ( ) ;
466462 let shouldUpdate = true ;
@@ -498,10 +494,10 @@ export class SessionManager implements Middleware {
498494 void this . setSessionFailedOpenBug ( "Language client failed to start: " + ( err instanceof Error ? err . message : "unknown" ) ) ;
499495 }
500496 } else if ( this . sessionDetails . status === "failed" ) { // Server started but indicated it failed
501- if ( this . sessionDetails . reason === "unsupported " ) {
497+ if ( this . sessionDetails . reason === "powerShellVersion " ) {
502498 void this . setSessionFailedGetPowerShell ( `PowerShell ${ this . sessionDetails . powerShellVersion } is not supported, please update!` ) ;
503- } else if ( this . sessionDetails . reason === "languageMode " ) {
504- this . setSessionFailure ( `PowerShell language features are disabled due to an unsupported LanguageMode: ${ this . sessionDetails . detail } ` ) ;
499+ } else if ( this . sessionDetails . reason === "dotNetVersion " ) { // Only applies to PowerShell 5.1
500+ void this . setSessionFailedGetDotNet ( ".NET Framework is out-of-date, please install at least 4.8!" ) ;
505501 } else {
506502 void this . setSessionFailedOpenBug ( `PowerShell could not be started for an unknown reason: ${ this . sessionDetails . reason } ` ) ;
507503 }
@@ -728,7 +724,7 @@ Type 'help' to get help.
728724 try {
729725 await this . languageClient . start ( ) ;
730726 } catch ( err ) {
731- this . setSessionFailure ( "Could not start language service: " , err instanceof Error ? err . message : "unknown" ) ;
727+ void this . setSessionFailedOpenBug ( "Could not start language service: " + ( err instanceof Error ? err . message : "unknown" ) ) ;
732728 return ;
733729 }
734730
@@ -761,6 +757,9 @@ Type 'help' to get help.
761757 const semver = new SemVer ( this . versionDetails . version ) ;
762758 this . languageStatusItem . text = `$(terminal-powershell) ${ semver . major } .${ semver . minor } ` ;
763759 this . languageStatusItem . detail += ` ${ this . versionDetails . commit } (${ this . versionDetails . architecture . toLowerCase ( ) } )` ;
760+ } else if ( this . PowerShellExeDetails ?. displayName ) { // In case it didn't start.
761+ this . languageStatusItem . text = `$(terminal-powershell) ${ this . PowerShellExeDetails . displayName } ` ;
762+ this . languageStatusItem . detail += `: ${ this . PowerShellExeDetails . exePath } ` ;
764763 }
765764
766765 if ( statusText ) {
@@ -799,11 +798,6 @@ Type 'help' to get help.
799798 this . setSessionStatus ( "Executing..." , SessionStatus . Busy ) ;
800799 }
801800
802- private setSessionFailure ( message : string , ...additionalMessages : string [ ] ) : void {
803- this . setSessionStatus ( "Initialization Error!" , SessionStatus . Failed ) ;
804- void this . logger . writeAndShowError ( message , ...additionalMessages ) ;
805- }
806-
807801 private async setSessionFailedOpenBug ( message : string ) : Promise < void > {
808802 this . setSessionStatus ( "Initialization Error!" , SessionStatus . Failed ) ;
809803 await this . logger . writeAndShowErrorWithActions ( message , [ {
@@ -825,6 +819,17 @@ Type 'help' to get help.
825819 ) ;
826820 }
827821
822+ private async setSessionFailedGetDotNet ( message : string ) : Promise < void > {
823+ this . setSessionStatus ( "Initialization Error!" , SessionStatus . Failed ) ;
824+ await this . logger . writeAndShowErrorWithActions ( message , [ {
825+ prompt : "Open .NET Framework Documentation" ,
826+ action : async ( ) : Promise < void > => {
827+ await vscode . env . openExternal (
828+ vscode . Uri . parse ( "https://dotnet.microsoft.com/en-us/download/dotnet-framework" ) ) ;
829+ } } ]
830+ ) ;
831+ }
832+
828833 private async changePowerShellDefaultVersion ( exePath : IPowerShellExeDetails ) : Promise < void > {
829834 this . suppressRestartPrompt = true ;
830835 try {
@@ -857,7 +862,8 @@ Type 'help' to get help.
857862 private async showSessionMenu ( ) : Promise < void > {
858863 const powershellExeFinder = new PowerShellExeFinder (
859864 this . platformDetails ,
860- this . sessionSettings . powerShellAdditionalExePaths ,
865+ // We don't pull from session settings because we want them fresh!
866+ getSettings ( ) . powerShellAdditionalExePaths ,
861867 this . logger ) ;
862868 const availablePowerShellExes = await powershellExeFinder . getAllAvailablePowerShellInstallations ( ) ;
863869
0 commit comments