Merge from vscode 12cb89c82e88e035f4ab630f1b9fcebac338dc03 (#5125)

This commit is contained in:
Alan Ren
2019-04-19 10:26:20 -07:00
committed by GitHub
parent f248260584
commit 0e168e36fc
17 changed files with 111 additions and 49 deletions

View File

@@ -3,9 +3,21 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IProgress, IProgressService2, IProgressStep, IProgressOptions } from 'vs/platform/progress/common/progress';
import { IProgress, IProgressService2, IProgressStep, ProgressLocation, IProgressOptions, IProgressNotificationOptions } from 'vs/platform/progress/common/progress';
import { MainThreadProgressShape, MainContext, IExtHostContext, ExtHostProgressShape, ExtHostContext } from '../common/extHost.protocol';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { Action } from 'vs/base/common/actions';
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { localize } from 'vs/nls';
class ManageExtensionAction extends Action {
constructor(id: ExtensionIdentifier, label: string, commandService: ICommandService) {
super(id.value, label, undefined, true, () => {
return commandService.executeCommand('_extensions.manage', id.value);
});
}
}
@extHostNamedCustomer(MainContext.MainThreadProgress)
export class MainThreadProgress implements MainThreadProgressShape {
@@ -16,7 +28,8 @@ export class MainThreadProgress implements MainThreadProgressShape {
constructor(
extHostContext: IExtHostContext,
@IProgressService2 progressService: IProgressService2
@IProgressService2 progressService: IProgressService2,
@ICommandService private readonly _commandService: ICommandService
) {
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostProgress);
this._progressService = progressService;
@@ -27,9 +40,19 @@ export class MainThreadProgress implements MainThreadProgressShape {
this._progress.clear();
}
$startProgress(handle: number, options: IProgressOptions): void {
$startProgress(handle: number, options: IProgressOptions, extension?: IExtensionDescription): void {
const task = this._createTask(handle);
if (options.location === ProgressLocation.Notification && extension && !extension.isUnderDevelopment) {
const notificationOptions: IProgressNotificationOptions = {
...options,
location: ProgressLocation.Notification,
secondaryActions: [new ManageExtensionAction(extension.identifier, localize('manageExtension', "Manage Extension"), this._commandService)]
};
options = notificationOptions;
}
this._progressService.withProgress(options, task, () => this._proxy.$acceptProgressCanceled(handle));
}