Skip to content

Commit 5f7dd08

Browse files
committed
Polish for slow task detection
1 parent bfc94e4 commit 5f7dd08

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,10 +2097,10 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
20972097
const progressManager = this._providerProgressManager;
20982098
const progressTimeout = setTimeout(() => {
20992099
if (progressManager) {
2100-
progressManager.showProgress = (stillProviding) => {
2100+
progressManager.showProgress = (stillProviding, total) => {
21012101
let message = undefined;
21022102
if (stillProviding.length > 0) {
2103-
message = nls.localize('pickProgressManager.description', 'Getting tasks from extensions. {0} extension(s) remaining: {1}', stillProviding.length, stillProviding.join(', '));
2103+
message = nls.localize('pickProgressManager.description', 'Detecting tasks ({0} of {1}): {2} in progress', total - stillProviding.length, total, stillProviding.join(', '));
21042104
}
21052105
picker.description = message;
21062106
};
@@ -2109,7 +2109,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
21092109
picker.customButton = false;
21102110
});
21112111
if (!progressManager.isDone) {
2112-
picker.customLabel = nls.localize('taskQuickPick.cancel', "Cancel Remaining Extensions");
2112+
picker.customLabel = nls.localize('taskQuickPick.cancel', "Stop detecting");
21132113
picker.onDidCustom(() => {
21142114
this._providerProgressManager?.cancel();
21152115
});

src/vs/workbench/contrib/tasks/browser/providerProgressManager.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import { CancellationTokenSource } from 'vs/base/common/cancellation';
1111
export class ProviderProgressMananger extends Disposable {
1212
private _onProviderComplete: Emitter<string> = new Emitter();
1313
private _stillProviding: Set<string> = new Set();
14+
private _totalProviders: number = 0;
1415
private _onDone: Emitter<void> = new Emitter();
1516
private _isDone: boolean = false;
16-
private _showProgress: ((remaining: string[]) => void) | undefined;
17+
private _showProgress: ((remaining: string[], total: number) => void) | undefined;
1718
public canceled: CancellationTokenSource = new CancellationTokenSource();
1819

1920
constructor() {
@@ -25,12 +26,13 @@ export class ProviderProgressMananger extends Disposable {
2526
this._onDone.fire();
2627
}
2728
if (this._showProgress) {
28-
this._showProgress(Array.from(this._stillProviding));
29+
this._showProgress(Array.from(this._stillProviding), this._totalProviders);
2930
}
3031
}));
3132
}
3233

3334
public addProvider(taskType: string, provider: Promise<TaskSet>) {
35+
this._totalProviders++;
3436
this._stillProviding.add(taskType);
3537
provider.then(() => this._onProviderComplete.fire(taskType));
3638
}
@@ -39,9 +41,9 @@ export class ProviderProgressMananger extends Disposable {
3941
this._register(this._onDone.event(onDoneListener));
4042
}
4143

42-
set showProgress(progressDisplayFunction: (remaining: string[]) => void) {
44+
set showProgress(progressDisplayFunction: (remaining: string[], total: number) => void) {
4345
this._showProgress = progressDisplayFunction;
44-
this._showProgress(Array.from(this._stillProviding));
46+
this._showProgress(Array.from(this._stillProviding), this._totalProviders);
4547
}
4648

4749
get isDone(): boolean {
@@ -51,7 +53,7 @@ export class ProviderProgressMananger extends Disposable {
5153
public cancel() {
5254
this._isDone = true;
5355
if (this._showProgress) {
54-
this._showProgress([]);
56+
this._showProgress([], 0);
5557
}
5658
this._onDone.fire();
5759
this.canceled.cancel();

0 commit comments

Comments
 (0)