actions: trigger actions wait for running state of workbench before checking for enablement

This commit is contained in:
isidor 2018-03-15 14:49:43 +01:00
parent 42c2387eb0
commit c1fb394dc6

View file

@ -96,21 +96,21 @@ Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionR
}
private _triggerAndDisposeAction(instantitationService: IInstantiationService, lifecycleService: ILifecycleService, descriptor: SyncActionDescriptor, args: any): Thenable<void> {
const actionInstance = instantitationService.createInstance(descriptor.syncDescriptor);
actionInstance.label = descriptor.label || actionInstance.label;
// don't run the action when not enabled
if (!actionInstance.enabled) {
actionInstance.dispose();
return void 0;
}
const from = args && args.from || 'keybinding';
// run action when workbench is created
return lifecycleService.when(LifecyclePhase.Running).then(() => {
const actionInstance = instantitationService.createInstance(descriptor.syncDescriptor);
try {
actionInstance.label = descriptor.label || actionInstance.label;
// don't run the action when not enabled
if (!actionInstance.enabled) {
actionInstance.dispose();
return void 0;
}
const from = args && args.from || 'keybinding';
return TPromise.as(actionInstance.run(undefined, { from })).then(() => {
actionInstance.dispose();
}, (err) => {
@ -124,4 +124,3 @@ Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionR
});
}
});