Skip to content

Commit 1b91613

Browse files
committed
WIP: Generalized busy indicator
1 parent 17b5294 commit 1b91613

File tree

3 files changed

+13
-29
lines changed

3 files changed

+13
-29
lines changed

src/features/Console.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ import { ICheckboxQuickPickItem, showCheckboxQuickPick } from "../controls/check
1010
import { Logger } from "../logging";
1111
import Settings = require("../settings");
1212
import { LanguageClientConsumer } from "../languageClientConsumer";
13-
import { SessionManager } from "../session";
1413

1514
export const EvaluateRequestType = new RequestType<IEvaluateRequestArguments, void, void>("evaluate");
1615
export const OutputNotificationType = new NotificationType<IOutputNotificationBody>("output");
17-
export const ExecutionStatusChangedNotificationType =
18-
new NotificationType<ExecutionStatus>("powerShell/executionStatusChanged");
1916

2017
export const ShowChoicePromptRequestType =
2118
new RequestType<IShowChoicePromptRequestArgs,
@@ -62,13 +59,6 @@ interface IShowInputPromptResponseBody {
6259
promptCancelled: boolean;
6360
}
6461

65-
enum ExecutionStatus {
66-
Pending,
67-
Running,
68-
Failed,
69-
Aborted,
70-
Completed,
71-
}
7262

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

187-
constructor(private log: Logger, private sessionManager: SessionManager) {
176+
constructor(private log: Logger) {
188177
super();
189178
this.commands = [
190179
vscode.commands.registerCommand("PowerShell.RunSelection", async () => {
@@ -242,22 +231,6 @@ export class ConsoleFeature extends LanguageClientConsumer {
242231
this.languageClient.onRequest(
243232
ShowInputPromptRequestType,
244233
(promptDetails) => showInputPrompt(promptDetails)),
245-
246-
// Set up status bar alerts for when PowerShell is executing a script.
247-
this.languageClient.onNotification(
248-
ExecutionStatusChangedNotificationType,
249-
(executionStatusDetails) => {
250-
switch (executionStatusDetails) {
251-
case ExecutionStatus.Running:
252-
this.sessionManager.setSessionBusyStatus();
253-
break;
254-
case ExecutionStatus.Completed:
255-
case ExecutionStatus.Aborted:
256-
case ExecutionStatus.Failed:
257-
this.sessionManager.setSessionRunningStatus();
258-
break;
259-
}
260-
})
261234
]
262235
}
263236
}

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<IPower
149149

150150
// Features and command registrations that require language client
151151
languageClientConsumers = [
152-
new ConsoleFeature(logger, sessionManager),
152+
new ConsoleFeature(logger),
153153
new ExpandAliasFeature(logger),
154154
new GetCommandsFeature(logger),
155155
new ShowHelpFeature(logger),

src/session.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ export type IReadSessionFileCallback = (details: IEditorServicesSessionDetails)
7373
export const SendKeyPressNotificationType =
7474
new NotificationType<void>("powerShell/sendKeyPress");
7575

76+
export const ExecutionBusyStatusNotificationType =
77+
new NotificationType<boolean>("powerShell/executionBusyStatus");
78+
7679
export const PowerShellVersionRequestType =
7780
new RequestType0<IPowerShellVersionDetails, void>(
7881
"powerShell/getVersion");
@@ -658,6 +661,14 @@ Type 'help' to get help.
658661
this.languageClient.onNotification(
659662
SendKeyPressNotificationType,
660663
() => { this.languageServerProcess.sendKeyPress(); }),
664+
665+
this.languageClient.onNotification(
666+
ExecutionBusyStatusNotificationType,
667+
(isBusy: boolean) => {
668+
if (isBusy) { this.setSessionBusyStatus(); }
669+
else { this.setSessionRunningStatus(); }
670+
}
671+
),
661672
]
662673

663674
try {

0 commit comments

Comments
 (0)