@@ -45,6 +45,8 @@ export class SessionManager implements Middleware {
4545 private focusConsoleOnExecute : boolean ;
4646 private platformDetails : IPlatformDetails ;
4747 private languageClientConsumers : LanguageClientConsumer [ ] = [ ] ;
48+ // @ts -ignore TODO: Don't ignore after we update our engine.
49+ private languageStatusItem : vscode . LanguageStatusItem ;
4850 private statusBarItem : vscode . StatusBarItem ;
4951 private languageServerProcess : PowerShellProcess ;
5052 private debugSessionProcess : PowerShellProcess ;
@@ -59,11 +61,7 @@ export class SessionManager implements Middleware {
5961 // Initialized by the start() method, since this requires settings
6062 private powershellExeFinder : PowerShellExeFinder ;
6163
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 ;
6765
6866 constructor (
6967 private log : Logger ,
@@ -398,7 +396,6 @@ export class SessionManager implements Middleware {
398396 }
399397
400398 private setStatusBarVersionString ( runspaceDetails : IRunspaceDetails ) {
401-
402399 const psVersion = runspaceDetails . powerShellVersion ;
403400
404401 let versionString =
@@ -410,9 +407,7 @@ export class SessionManager implements Middleware {
410407 versionString += ` [${ runspaceDetails . connectionString } ]` ;
411408 }
412409
413- this . setSessionStatus (
414- versionString ,
415- SessionStatus . Running ) ;
410+ this . setSessionStatus ( versionString , SessionStatus . Running ) ;
416411 }
417412
418413 private registerCommands ( ) : void {
@@ -426,10 +421,7 @@ export class SessionManager implements Middleware {
426421 }
427422
428423 private startPowerShell ( ) {
429-
430- this . setSessionStatus (
431- "Starting PowerShell..." ,
432- SessionStatus . Initializing ) ;
424+ this . setSessionStatus ( "Starting..." , SessionStatus . Initializing ) ;
433425
434426 const sessionFilePath =
435427 utils . getSessionFilePath (
@@ -448,7 +440,7 @@ export class SessionManager implements Middleware {
448440 this . languageServerProcess . onExited (
449441 ( ) => {
450442 if ( this . sessionStatus === SessionStatus . Running ) {
451- this . setSessionStatus ( "Session exited " , SessionStatus . Failed ) ;
443+ this . setSessionStatus ( "Session Exited " , SessionStatus . Failed ) ;
452444 this . promptForRestart ( ) ;
453445 }
454446 } ) ;
@@ -632,7 +624,14 @@ export class SessionManager implements Middleware {
632624 }
633625
634626 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 ) {
636635 // Create the status bar item and place it right next
637636 // to the language indicator
638637 this . statusBarItem =
@@ -641,7 +640,7 @@ export class SessionManager implements Middleware {
641640 1 ) ;
642641
643642 this . statusBarItem . command = this . ShowSessionMenuCommandName ;
644- this . statusBarItem . tooltip = "Show PowerShell Session Menu" ;
643+ this . statusBarItem . tooltip = statusTitle ;
645644 this . statusBarItem . show ( ) ;
646645 vscode . window . onDidChangeActiveTextEditor ( ( textEditor ) => {
647646 if ( textEditor === undefined
@@ -656,36 +655,58 @@ export class SessionManager implements Middleware {
656655
657656 private setSessionStatus ( statusText : string , status : SessionStatus ) : void {
658657 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 ;
679704 }
680- this . statusBarItem . text += " " + statusText ;
681705 }
682706
683707 private setSessionFailure ( message : string , ...additionalMessages : string [ ] ) {
684708 this . log . writeAndShowError ( message , ...additionalMessages ) ;
685-
686- this . setSessionStatus (
687- "Initialization Error" ,
688- SessionStatus . Failed ) ;
709+ this . setSessionStatus ( "Initialization Error" , SessionStatus . Failed ) ;
689710 }
690711
691712 private async changePowerShellDefaultVersion ( exePath : IPowerShellExeDetails ) {
0 commit comments