From 1b9161325715e5845cf9a5a9970b7eccd8c4198e Mon Sep 17 00:00:00 2001 From: Andy Jordan Date: Fri, 30 Sep 2022 09:22:36 -0700 Subject: [PATCH] WIP: Generalized busy indicator --- src/features/Console.ts | 29 +---------------------------- src/main.ts | 2 +- src/session.ts | 11 +++++++++++ 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/features/Console.ts b/src/features/Console.ts index 673c79108b..e1ad971813 100644 --- a/src/features/Console.ts +++ b/src/features/Console.ts @@ -10,12 +10,9 @@ import { ICheckboxQuickPickItem, showCheckboxQuickPick } from "../controls/check import { Logger } from "../logging"; import Settings = require("../settings"); import { LanguageClientConsumer } from "../languageClientConsumer"; -import { SessionManager } from "../session"; export const EvaluateRequestType = new RequestType("evaluate"); export const OutputNotificationType = new NotificationType("output"); -export const ExecutionStatusChangedNotificationType = - new NotificationType("powerShell/executionStatusChanged"); export const ShowChoicePromptRequestType = new RequestType) => void; - constructor(private log: Logger, private sessionManager: SessionManager) { + constructor(private log: Logger) { super(); this.commands = [ vscode.commands.registerCommand("PowerShell.RunSelection", async () => { @@ -242,22 +231,6 @@ export class ConsoleFeature extends LanguageClientConsumer { this.languageClient.onRequest( ShowInputPromptRequestType, (promptDetails) => showInputPrompt(promptDetails)), - - // Set up status bar alerts for when PowerShell is executing a script. - this.languageClient.onNotification( - ExecutionStatusChangedNotificationType, - (executionStatusDetails) => { - switch (executionStatusDetails) { - case ExecutionStatus.Running: - this.sessionManager.setSessionBusyStatus(); - break; - case ExecutionStatus.Completed: - case ExecutionStatus.Aborted: - case ExecutionStatus.Failed: - this.sessionManager.setSessionRunningStatus(); - break; - } - }) ] } } diff --git a/src/main.ts b/src/main.ts index d5dfd9ba74..eaccd6e405 100644 --- a/src/main.ts +++ b/src/main.ts @@ -149,7 +149,7 @@ export async function activate(context: vscode.ExtensionContext): Promise("powerShell/sendKeyPress"); +export const ExecutionBusyStatusNotificationType = + new NotificationType("powerShell/executionBusyStatus"); + export const PowerShellVersionRequestType = new RequestType0( "powerShell/getVersion"); @@ -658,6 +661,14 @@ Type 'help' to get help. this.languageClient.onNotification( SendKeyPressNotificationType, () => { this.languageServerProcess.sendKeyPress(); }), + + this.languageClient.onNotification( + ExecutionBusyStatusNotificationType, + (isBusy: boolean) => { + if (isBusy) { this.setSessionBusyStatus(); } + else { this.setSessionRunningStatus(); } + } + ), ] try {