@@ -246,6 +246,15 @@ export class SessionManager {
246
246
// Start the language service client
247
247
this . startLanguageClient ( sessionDetails . languageServicePort ) ;
248
248
}
249
+ else if ( response [ "status" ] === "failed" ) {
250
+ if ( response [ "reason" ] === "unsupported" ) {
251
+ this . setSessionFailure (
252
+ `PowerShell language features are only supported on PowerShell version 3 and above. The current version is ${ response [ "powerShellVersion" ] } .` )
253
+ }
254
+ else {
255
+ this . setSessionFailure ( `PowerShell could not be started for an unknown reason '${ response [ "reason" ] } '` )
256
+ }
257
+ }
249
258
else {
250
259
// TODO: Handle other response cases
251
260
}
@@ -354,15 +363,13 @@ export class SessionManager {
354
363
} ,
355
364
( reason ) => {
356
365
this . setSessionFailure ( "Could not start language service: " , reason ) ;
357
- this . updateExtensionFeatures ( undefined ) ;
358
366
} ) ;
359
367
360
368
this . languageServerClient . start ( ) ;
361
369
}
362
370
catch ( e )
363
371
{
364
372
this . setSessionFailure ( "The language service could not be started: " , e ) ;
365
- this . updateExtensionFeatures ( undefined ) ;
366
373
}
367
374
}
368
375
@@ -511,15 +518,34 @@ export class SessionManager {
511
518
}
512
519
513
520
private showSessionMenu ( ) {
514
- var menuItems : SessionMenuItem [ ] = [
515
- new SessionMenuItem (
516
- `Current session: PowerShell ${ this . versionDetails . displayVersion } (${ this . versionDetails . architecture } ) ${ this . versionDetails . edition } Edition [${ this . versionDetails . version } ]` ,
517
- ( ) => { vscode . commands . executeCommand ( "PowerShell.ShowLogs" ) ; } ) ,
521
+ var menuItems : SessionMenuItem [ ] = [ ] ;
518
522
519
- new SessionMenuItem (
520
- "Restart Current Session" ,
521
- ( ) => { this . restartSession ( ) ; } ) ,
522
- ] ;
523
+ if ( this . sessionStatus === SessionStatus . Initializing ||
524
+ this . sessionStatus === SessionStatus . NotStarted ||
525
+ this . sessionStatus === SessionStatus . Stopping ) {
526
+
527
+ // Don't show a menu for these states
528
+ return ;
529
+ }
530
+
531
+ if ( this . sessionStatus === SessionStatus . Running ) {
532
+ menuItems = [
533
+ new SessionMenuItem (
534
+ `Current session: PowerShell ${ this . versionDetails . displayVersion } (${ this . versionDetails . architecture } ) ${ this . versionDetails . edition } Edition [${ this . versionDetails . version } ]` ,
535
+ ( ) => { vscode . commands . executeCommand ( "PowerShell.ShowLogs" ) ; } ) ,
536
+
537
+ new SessionMenuItem (
538
+ "Restart Current Session" ,
539
+ ( ) => { this . restartSession ( ) ; } ) ,
540
+ ] ;
541
+ }
542
+ else if ( this . sessionStatus === SessionStatus . Failed ) {
543
+ menuItems = [
544
+ new SessionMenuItem (
545
+ `Session initialization failed, click here to show PowerShell extension logs` ,
546
+ ( ) => { vscode . commands . executeCommand ( "PowerShell.ShowLogs" ) ; } ) ,
547
+ ] ;
548
+ }
523
549
524
550
if ( this . isWindowsOS ) {
525
551
var item32 =
0 commit comments