@@ -45,6 +45,8 @@ export class SessionManager implements Middleware {
45
45
private focusConsoleOnExecute : boolean ;
46
46
private platformDetails : IPlatformDetails ;
47
47
private languageClientConsumers : LanguageClientConsumer [ ] = [ ] ;
48
+ // @ts -ignore TODO: Don't ignore after we update our engine.
49
+ private languageStatusItem : vscode . LanguageStatusItem ;
48
50
private statusBarItem : vscode . StatusBarItem ;
49
51
private languageServerProcess : PowerShellProcess ;
50
52
private debugSessionProcess : PowerShellProcess ;
@@ -59,11 +61,7 @@ export class SessionManager implements Middleware {
59
61
// Initialized by the start() method, since this requires settings
60
62
private powershellExeFinder : PowerShellExeFinder ;
61
63
62
- // When in development mode, VS Code's session ID is a fake
63
- // value of "someValue.machineId". Use that to detect dev
64
- // mode for now until Microsoft/vscode#10272 gets implemented.
65
- public readonly InDevelopmentMode =
66
- vscode . env . sessionId === "someValue.sessionId" ;
64
+ public readonly InDevelopmentMode = vscode . ExtensionMode . Development ;
67
65
68
66
constructor (
69
67
private log : Logger ,
@@ -398,7 +396,6 @@ export class SessionManager implements Middleware {
398
396
}
399
397
400
398
private setStatusBarVersionString ( runspaceDetails : IRunspaceDetails ) {
401
-
402
399
const psVersion = runspaceDetails . powerShellVersion ;
403
400
404
401
let versionString =
@@ -410,9 +407,7 @@ export class SessionManager implements Middleware {
410
407
versionString += ` [${ runspaceDetails . connectionString } ]` ;
411
408
}
412
409
413
- this . setSessionStatus (
414
- versionString ,
415
- SessionStatus . Running ) ;
410
+ this . setSessionStatus ( versionString , SessionStatus . Running ) ;
416
411
}
417
412
418
413
private registerCommands ( ) : void {
@@ -426,10 +421,7 @@ export class SessionManager implements Middleware {
426
421
}
427
422
428
423
private startPowerShell ( ) {
429
-
430
- this . setSessionStatus (
431
- "Starting PowerShell..." ,
432
- SessionStatus . Initializing ) ;
424
+ this . setSessionStatus ( "Starting..." , SessionStatus . Initializing ) ;
433
425
434
426
const sessionFilePath =
435
427
utils . getSessionFilePath (
@@ -448,7 +440,7 @@ export class SessionManager implements Middleware {
448
440
this . languageServerProcess . onExited (
449
441
( ) => {
450
442
if ( this . sessionStatus === SessionStatus . Running ) {
451
- this . setSessionStatus ( "Session exited " , SessionStatus . Failed ) ;
443
+ this . setSessionStatus ( "Session Exited " , SessionStatus . Failed ) ;
452
444
this . promptForRestart ( ) ;
453
445
}
454
446
} ) ;
@@ -632,7 +624,14 @@ export class SessionManager implements Middleware {
632
624
}
633
625
634
626
private createStatusBarItem ( ) {
635
- if ( this . statusBarItem === undefined ) {
627
+ const statusTitle : string = "Show PowerShell Session Menu" ;
628
+ // TODO: Remove old status bar logic when we update our engine.
629
+ if ( semver . gte ( vscode . version , "1.65.0" ) && this . languageStatusItem === undefined ) {
630
+ // @ts -ignore
631
+ this . languageStatusItem = vscode . languages . createLanguageStatusItem ( "powershell" , this . documentSelector ) ;
632
+ this . languageStatusItem . command = { title : statusTitle , command : this . ShowSessionMenuCommandName } ;
633
+ this . languageStatusItem . text = "$(terminal-powershell)" ;
634
+ } else if ( this . statusBarItem === undefined ) {
636
635
// Create the status bar item and place it right next
637
636
// to the language indicator
638
637
this . statusBarItem =
@@ -641,7 +640,7 @@ export class SessionManager implements Middleware {
641
640
1 ) ;
642
641
643
642
this . statusBarItem . command = this . ShowSessionMenuCommandName ;
644
- this . statusBarItem . tooltip = "Show PowerShell Session Menu" ;
643
+ this . statusBarItem . tooltip = statusTitle ;
645
644
this . statusBarItem . show ( ) ;
646
645
vscode . window . onDidChangeActiveTextEditor ( ( textEditor ) => {
647
646
if ( textEditor === undefined
@@ -656,36 +655,58 @@ export class SessionManager implements Middleware {
656
655
657
656
private setSessionStatus ( statusText : string , status : SessionStatus ) : void {
658
657
this . sessionStatus = status ;
659
- switch ( status ) {
660
- case SessionStatus . Running :
661
- case SessionStatus . NeverStarted :
662
- case SessionStatus . NotStarted :
663
- this . statusBarItem . text = "$(terminal-powershell)" ;
664
- // These have to be reset because this function mutates state.
665
- this . statusBarItem . color = undefined ;
666
- this . statusBarItem . backgroundColor = undefined ;
667
- break ;
668
- case SessionStatus . Initializing :
669
- case SessionStatus . Stopping :
670
- this . statusBarItem . text = "$(sync)" ;
671
- this . statusBarItem . color = new vscode . ThemeColor ( "statusBarItem.warningForeground" ) ;
672
- this . statusBarItem . backgroundColor = new vscode . ThemeColor ( "statusBarItem.warningBackground" ) ;
673
- break ;
674
- case SessionStatus . Failed :
675
- this . statusBarItem . text = "$(alert)" ;
676
- this . statusBarItem . color = new vscode . ThemeColor ( "statusBarItem.errorForeground" ) ;
677
- this . statusBarItem . backgroundColor = new vscode . ThemeColor ( "statusBarItem.errorBackground" ) ;
678
- break ;
658
+ // TODO: Remove old status bar logic when we update our engine.
659
+ if ( semver . gte ( vscode . version , "1.65.0" ) ) {
660
+ this . languageStatusItem . detail = "PowerShell " + statusText ;
661
+ switch ( status ) {
662
+ case SessionStatus . Running :
663
+ case SessionStatus . NeverStarted :
664
+ case SessionStatus . NotStarted :
665
+ this . languageStatusItem . busy = false ;
666
+ // @ts -ignore
667
+ this . languageStatusItem . severity = vscode . LanguageStatusSeverity . Information ;
668
+ break ;
669
+ case SessionStatus . Initializing :
670
+ case SessionStatus . Stopping :
671
+ this . languageStatusItem . busy = true ;
672
+ // @ts -ignore
673
+ this . languageStatusItem . severity = vscode . LanguageStatusSeverity . Warning ;
674
+ break ;
675
+ case SessionStatus . Failed :
676
+ this . languageStatusItem . busy = false ;
677
+ // @ts -ignore
678
+ this . languageStatusItem . severity = vscode . LanguageStatusSeverity . Error ;
679
+ break ;
680
+ }
681
+ } else {
682
+ switch ( status ) {
683
+ case SessionStatus . Running :
684
+ case SessionStatus . NeverStarted :
685
+ case SessionStatus . NotStarted :
686
+ this . statusBarItem . text = "$(terminal-powershell)" ;
687
+ // These have to be reset because this function mutates state.
688
+ this . statusBarItem . color = undefined ;
689
+ this . statusBarItem . backgroundColor = undefined ;
690
+ break ;
691
+ case SessionStatus . Initializing :
692
+ case SessionStatus . Stopping :
693
+ this . statusBarItem . text = "$(sync)" ;
694
+ this . statusBarItem . color = new vscode . ThemeColor ( "statusBarItem.warningForeground" ) ;
695
+ this . statusBarItem . backgroundColor = new vscode . ThemeColor ( "statusBarItem.warningBackground" ) ;
696
+ break ;
697
+ case SessionStatus . Failed :
698
+ this . statusBarItem . text = "$(alert)" ;
699
+ this . statusBarItem . color = new vscode . ThemeColor ( "statusBarItem.errorForeground" ) ;
700
+ this . statusBarItem . backgroundColor = new vscode . ThemeColor ( "statusBarItem.errorBackground" ) ;
701
+ break ;
702
+ }
703
+ this . statusBarItem . text += " " + statusText ;
679
704
}
680
- this . statusBarItem . text += " " + statusText ;
681
705
}
682
706
683
707
private setSessionFailure ( message : string , ...additionalMessages : string [ ] ) {
684
708
this . log . writeAndShowError ( message , ...additionalMessages ) ;
685
-
686
- this . setSessionStatus (
687
- "Initialization Error" ,
688
- SessionStatus . Failed ) ;
709
+ this . setSessionStatus ( "Initialization Error" , SessionStatus . Failed ) ;
689
710
}
690
711
691
712
private async changePowerShellDefaultVersion ( exePath : IPowerShellExeDetails ) {
0 commit comments