Skip to content

Commit eb4ebee

Browse files
author
Eric Amodio
committed
Closes microsoft#92421 - view-level progress api
1 parent cfc1ab4 commit eb4ebee

6 files changed

Lines changed: 32 additions & 5 deletions

File tree

src/vs/platform/progress/common/progress.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export const enum ProgressLocation {
4545
Extensions = 5,
4646
Window = 10,
4747
Notification = 15,
48-
Dialog = 20
48+
Dialog = 20,
49+
View = 25
4950
}
5051

5152
export interface IProgressOptions {

src/vs/vscode.proposed.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,4 +1824,24 @@ declare module 'vscode' {
18241824
}
18251825

18261826
//#endregion
1827+
1828+
//#region https://github.com/microsoft/vscode/issues/92421
1829+
1830+
export enum ProgressLocation {
1831+
/**
1832+
* Show progress for a view, as progress bar inside the view (when visible),
1833+
* and as an overlay on the activity bar icon. Doesn't support cancellation or discrete progress.
1834+
*/
1835+
View = 25,
1836+
}
1837+
1838+
export interface ProgressOptions {
1839+
/**
1840+
* The target view identifier for showing progress when using [ProgressLocation.View](#ProgressLocation.View).
1841+
*/
1842+
viewId?: string
1843+
}
1844+
1845+
//#endregion
1846+
18271847
}

src/vs/workbench/api/common/extHost.api.impl.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
540540
return extHostProgress.withProgress(extension, { location: extHostTypes.ProgressLocation.SourceControl }, (progress, token) => task({ report(n: number) { /*noop*/ } }));
541541
},
542542
withProgress<R>(options: vscode.ProgressOptions, task: (progress: vscode.Progress<{ message?: string; worked?: number }>, token: vscode.CancellationToken) => Thenable<R>) {
543+
if (options.location === extHostTypes.ProgressLocation.View) {
544+
checkProposedApiEnabled(extension);
545+
}
543546
return extHostProgress.withProgress(extension, options, task);
544547
},
545548
createOutputChannel(name: string): vscode.OutputChannel {

src/vs/workbench/api/common/extHostProgress.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ export class ExtHostProgress implements ExtHostProgressShape {
2424

2525
withProgress<R>(extension: IExtensionDescription, options: ProgressOptions, task: (progress: Progress<IProgressStep>, token: CancellationToken) => Thenable<R>): Thenable<R> {
2626
const handle = this._handles++;
27-
const { title, location, cancellable } = options;
27+
const { title, location, cancellable, viewId } = options;
2828
const source = localize('extensionSource', "{0} (Extension)", extension.displayName || extension.name);
29-
this._proxy.$startProgress(handle, { location: ProgressLocation.from(location), title, source, cancellable }, extension);
29+
30+
this._proxy.$startProgress(handle, { location: ProgressLocation.from(location, viewId), title, source, cancellable }, extension);
3031
return this._withProgress(handle, task, !!cancellable);
3132
}
3233

src/vs/workbench/api/common/extHostTypeConverters.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,11 +1093,12 @@ export namespace EndOfLine {
10931093
}
10941094

10951095
export namespace ProgressLocation {
1096-
export function from(loc: vscode.ProgressLocation): MainProgressLocation {
1096+
export function from(loc: vscode.ProgressLocation, viewId?: string): MainProgressLocation | string {
10971097
switch (loc) {
10981098
case types.ProgressLocation.SourceControl: return MainProgressLocation.Scm;
10991099
case types.ProgressLocation.Window: return MainProgressLocation.Window;
11001100
case types.ProgressLocation.Notification: return MainProgressLocation.Notification;
1101+
case types.ProgressLocation.View: return viewId ?? '';
11011102
}
11021103
throw new Error(`Unknown 'ProgressLocation'`);
11031104
}

src/vs/workbench/api/common/extHostTypes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2082,7 +2082,8 @@ export class Task implements vscode.Task2 {
20822082
export enum ProgressLocation {
20832083
SourceControl = 1,
20842084
Window = 10,
2085-
Notification = 15
2085+
Notification = 15,
2086+
View = 25
20862087
}
20872088

20882089
@es5ClassCompat

0 commit comments

Comments
 (0)