Skip to content

Commit 7ede29b

Browse files
committed
Display entered runspace details in status bar
This change adds runspace connection details to the status bar indicator when the user enters a remote session or PowerShell process through the editing session.
1 parent 85af84e commit 7ede29b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/session.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,23 @@ export class SessionManager {
189189
}
190190
}
191191

192+
private setStatusBarVersionString(
193+
runspaceDetails: RunspaceDetails) {
194+
195+
var versionString =
196+
this.versionDetails.architecture === "x86"
197+
? `${runspaceDetails.powerShellVersion.displayVersion} (${runspaceDetails.powerShellVersion.architecture})`
198+
: runspaceDetails.powerShellVersion.displayVersion;
199+
200+
if (runspaceDetails.runspaceType != RunspaceType.Local) {
201+
versionString += ` [${runspaceDetails.connectionString}]`
202+
}
203+
204+
this.setSessionStatus(
205+
versionString,
206+
SessionStatus.Running);
207+
}
208+
192209
private registerCommands() : void {
193210
this.registeredCommands = [
194211
vscode.commands.registerCommand('PowerShell.RestartSession', () => { this.restartSession(); }),
@@ -365,6 +382,10 @@ export class SessionManager {
365382
this.setSessionFailure("Could not start language service: ", reason);
366383
});
367384

385+
this.languageServerClient.onNotification(
386+
RunspaceChangedEvent.type,
387+
(runspaceDetails) => { this.setStatusBarVersionString(runspaceDetails); });
388+
368389
this.languageServerClient.start();
369390
}
370391
catch (e)
@@ -623,3 +644,20 @@ export interface PowerShellVersionDetails {
623644
edition: string;
624645
architecture: string;
625646
}
647+
648+
export enum RunspaceType {
649+
Local,
650+
Process,
651+
Remote
652+
}
653+
654+
export interface RunspaceDetails {
655+
powerShellVersion: PowerShellVersionDetails;
656+
runspaceType: RunspaceType;
657+
connectionString: string;
658+
}
659+
660+
export namespace RunspaceChangedEvent {
661+
export const type: NotificationType<RunspaceDetails> =
662+
{ get method() { return 'powerShell/runspaceChanged'; } };
663+
}

0 commit comments

Comments
 (0)