Skip to content

Commit ac643e1

Browse files
committed
show progress when activating an extension via onCommand:Foo, microsoft#59645
1 parent d9017cd commit ac643e1

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

build/lib/i18n.resources.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@
166166
"name": "vs/workbench/services/bulkEdit",
167167
"project": "vscode-workbench"
168168
},
169+
{
170+
"name": "vs/workbench/services/commands",
171+
"project": "vscode-workbench"
172+
},
169173
{
170174
"name": "vs/workbench/services/configuration",
171175
"project": "vscode-workbench"

src/vs/workbench/services/commands/common/commandService.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
99
import { Event, Emitter } from 'vs/base/common/event';
1010
import { Disposable } from 'vs/base/common/lifecycle';
1111
import { ILogService } from 'vs/platform/log/common/log';
12+
import { IProgressService2, ProgressLocation } from 'vs/platform/progress/common/progress';
13+
import { localize } from 'vs/nls';
1214

1315
export class CommandService extends Disposable implements ICommandService {
1416

@@ -22,7 +24,8 @@ export class CommandService extends Disposable implements ICommandService {
2224
constructor(
2325
@IInstantiationService private readonly _instantiationService: IInstantiationService,
2426
@IExtensionService private readonly _extensionService: IExtensionService,
25-
@ILogService private readonly _logService: ILogService
27+
@ILogService private readonly _logService: ILogService,
28+
@IProgressService2 private readonly _progressService: IProgressService2,
2629
) {
2730
super();
2831
this._extensionService.whenInstalledExtensionsRegistered().then(value => this._extensionHostIsReady = value);
@@ -35,17 +38,23 @@ export class CommandService extends Disposable implements ICommandService {
3538
// we don't wait for it when the extension
3639
// host didn't yet start and the command is already registered
3740

38-
const activation = Promise.resolve(this._extensionService.activateByEvent(`onCommand:${id}`));
41+
const activation: Thenable<any> = this._extensionService.activateByEvent(`onCommand:${id}`);
3942
const commandIsRegistered = !!CommandsRegistry.getCommand(id);
4043

4144
if (!this._extensionHostIsReady && commandIsRegistered) {
4245
return this._tryExecuteCommand(id, args);
4346
} else {
44-
let waitFor: Promise<any> = activation;
47+
let waitFor = activation;
4548
if (!commandIsRegistered) {
4649
waitFor = Promise.all([activation, this._extensionService.activateByEvent(`*`)]);
4750
}
48-
return waitFor.then(_ => this._tryExecuteCommand(id, args));
51+
52+
this._progressService.withProgress({
53+
location: ProgressLocation.Window,
54+
title: localize('activating', "Activating extensions for command '{0}'...", id)
55+
}, () => waitFor);
56+
57+
return (waitFor as Promise<any>).then(_ => this._tryExecuteCommand(id, args));
4958
}
5059
}
5160

0 commit comments

Comments
 (0)