Skip to content

Commit

Permalink
Closes #92421 - view-level progress api
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Amodio committed Mar 11, 2020
1 parent cfc1ab4 commit eb4ebee
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/vs/platform/progress/common/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export const enum ProgressLocation {
Extensions = 5,
Window = 10,
Notification = 15,
Dialog = 20
Dialog = 20,
View = 25
}

export interface IProgressOptions {
Expand Down
20 changes: 20 additions & 0 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1824,4 +1824,24 @@ declare module 'vscode' {
}

//#endregion

//#region https://github.com/microsoft/vscode/issues/92421

export enum ProgressLocation {
/**
* Show progress for a view, as progress bar inside the view (when visible),
* and as an overlay on the activity bar icon. Doesn't support cancellation or discrete progress.
*/
View = 25,
}

export interface ProgressOptions {
/**
* The target view identifier for showing progress when using [ProgressLocation.View](#ProgressLocation.View).
*/
viewId?: string
}

//#endregion

}
3 changes: 3 additions & 0 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return extHostProgress.withProgress(extension, { location: extHostTypes.ProgressLocation.SourceControl }, (progress, token) => task({ report(n: number) { /*noop*/ } }));
},
withProgress<R>(options: vscode.ProgressOptions, task: (progress: vscode.Progress<{ message?: string; worked?: number }>, token: vscode.CancellationToken) => Thenable<R>) {
if (options.location === extHostTypes.ProgressLocation.View) {
checkProposedApiEnabled(extension);
}
return extHostProgress.withProgress(extension, options, task);
},
createOutputChannel(name: string): vscode.OutputChannel {
Expand Down
5 changes: 3 additions & 2 deletions src/vs/workbench/api/common/extHostProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ export class ExtHostProgress implements ExtHostProgressShape {

withProgress<R>(extension: IExtensionDescription, options: ProgressOptions, task: (progress: Progress<IProgressStep>, token: CancellationToken) => Thenable<R>): Thenable<R> {
const handle = this._handles++;
const { title, location, cancellable } = options;
const { title, location, cancellable, viewId } = options;
const source = localize('extensionSource', "{0} (Extension)", extension.displayName || extension.name);
this._proxy.$startProgress(handle, { location: ProgressLocation.from(location), title, source, cancellable }, extension);

this._proxy.$startProgress(handle, { location: ProgressLocation.from(location, viewId), title, source, cancellable }, extension);
return this._withProgress(handle, task, !!cancellable);
}

Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/api/common/extHostTypeConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1093,11 +1093,12 @@ export namespace EndOfLine {
}

export namespace ProgressLocation {
export function from(loc: vscode.ProgressLocation): MainProgressLocation {
export function from(loc: vscode.ProgressLocation, viewId?: string): MainProgressLocation | string {
switch (loc) {
case types.ProgressLocation.SourceControl: return MainProgressLocation.Scm;
case types.ProgressLocation.Window: return MainProgressLocation.Window;
case types.ProgressLocation.Notification: return MainProgressLocation.Notification;
case types.ProgressLocation.View: return viewId ?? '';
}
throw new Error(`Unknown 'ProgressLocation'`);
}
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,8 @@ export class Task implements vscode.Task2 {
export enum ProgressLocation {
SourceControl = 1,
Window = 10,
Notification = 15
Notification = 15,
View = 25
}

@es5ClassCompat
Expand Down

0 comments on commit eb4ebee

Please sign in to comment.