Skip to content

Commit

Permalink
Protect from throwing IWorkbenchExtensionEnablementService.isEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Oct 16, 2020
1 parent f3399d0 commit d81f0e4
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
let toAdd: IExtension[] = [];
let toRemove: string[] = [];
for (const extension of extensions) {
if (this._extensionEnablementService.isEnabled(extension)) {
if (this._safeInvokeIsEnabled(extension)) {
// an extension has been enabled
toAdd.push(extension);
} else {
Expand All @@ -154,7 +154,7 @@ export abstract class AbstractExtensionService extends Disposable implements IEx

this._register(this._extensionManagementService.onDidInstallExtension((event) => {
if (event.local) {
if (this._extensionEnablementService.isEnabled(event.local)) {
if (this._safeInvokeIsEnabled(event.local)) {
// an extension has been installed
this._handleDeltaExtensions(new DeltaExtensionsQueueItem([event.local], []));
}
Expand Down Expand Up @@ -618,7 +618,15 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
return false;
}

return this._extensionEnablementService.isEnabled(toExtension(extension));
return this._safeInvokeIsEnabled(toExtension(extension));
}

protected _safeInvokeIsEnabled(extension: IExtension): boolean {
try {
return this._extensionEnablementService.isEnabled(extension);
} catch (err) {
return false;
}
}

protected _doHandleExtensionPoints(affectedExtensions: IExtensionDescription[]): void {
Expand Down

0 comments on commit d81f0e4

Please sign in to comment.