Skip to content

Commit

Permalink
WIP: Generalized busy indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleejordan committed Sep 30, 2022
1 parent 17b5294 commit 1b91613
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 29 deletions.
29 changes: 1 addition & 28 deletions src/features/Console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IEvaluateRequestArguments, void, void>("evaluate");
export const OutputNotificationType = new NotificationType<IOutputNotificationBody>("output");
export const ExecutionStatusChangedNotificationType =
new NotificationType<ExecutionStatus>("powerShell/executionStatusChanged");

export const ShowChoicePromptRequestType =
new RequestType<IShowChoicePromptRequestArgs,
Expand Down Expand Up @@ -62,13 +59,6 @@ interface IShowInputPromptResponseBody {
promptCancelled: boolean;
}

enum ExecutionStatus {
Pending,
Running,
Failed,
Aborted,
Completed,
}

function showChoicePrompt(
promptDetails: IShowChoicePromptRequestArgs,
Expand Down Expand Up @@ -182,9 +172,8 @@ function onInputEntered(responseText: string): IShowInputPromptResponseBody {
export class ConsoleFeature extends LanguageClientConsumer {
private commands: vscode.Disposable[];
private handlers: vscode.Disposable[];
private resolveStatusBarPromise: (value?: {} | PromiseLike<{}>) => void;

constructor(private log: Logger, private sessionManager: SessionManager) {
constructor(private log: Logger) {
super();
this.commands = [
vscode.commands.registerCommand("PowerShell.RunSelection", async () => {
Expand Down Expand Up @@ -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;
}
})
]
}
}
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<IPower

// Features and command registrations that require language client
languageClientConsumers = [
new ConsoleFeature(logger, sessionManager),
new ConsoleFeature(logger),
new ExpandAliasFeature(logger),
new GetCommandsFeature(logger),
new ShowHelpFeature(logger),
Expand Down
11 changes: 11 additions & 0 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ export type IReadSessionFileCallback = (details: IEditorServicesSessionDetails)
export const SendKeyPressNotificationType =
new NotificationType<void>("powerShell/sendKeyPress");

export const ExecutionBusyStatusNotificationType =
new NotificationType<boolean>("powerShell/executionBusyStatus");

export const PowerShellVersionRequestType =
new RequestType0<IPowerShellVersionDetails, void>(
"powerShell/getVersion");
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 1b91613

Please sign in to comment.