diff --git a/src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchService.ts b/src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchService.ts index b3c5485a751be30e7373b9ffc2c3c11020128c04..96dc87844e645d431abf4ac9639a0cc7ed3c54f9 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchService.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchService.ts @@ -273,6 +273,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService { private uninstalling: IActiveExtension[] = []; private installed: Extension[] = []; private syncDelayer: ThrottledDelayer; + private autoUpdateDelayer: ThrottledDelayer; private disposables: IDisposable[] = []; private _onChange: Emitter = new Emitter(); @@ -296,6 +297,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService { extensionService.onDidUninstallExtension(this.onDidUninstallExtension, this, this.disposables); this.syncDelayer = new ThrottledDelayer(ExtensionsWorkbenchService.SyncPeriod); + this.autoUpdateDelayer = new ThrottledDelayer(1000); chain(urlService.onOpenURL) .filter(uri => /^extension/.test(uri.path)) @@ -347,6 +349,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService { if (installed) { installed.gallery = gallery; this._onChange.fire(); + this.eventuallyAutoUpdateExtensions(); return installed; } @@ -371,16 +374,28 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService { return TPromise.as(null); } - return this.queryGallery({ ids, pageSize: ids.length }).then(() => { - const config = this.configurationService.getConfiguration(ConfigurationKey); + return this.queryGallery({ ids, pageSize: ids.length }) as TPromise; + } - if (!config.autoUpdate) { - return; - } + private eventuallyAutoUpdateExtensions(): void { + this.autoUpdateDelayer.trigger(() => this.autoUpdateExtensions()) + .done(null, err => this.onError(err)); + } - const action = this.instantiationService.createInstance(UpdateAllAction, UpdateAllAction.ID, UpdateAllAction.LABEL); - return action.enabled && action.run(); - }); + private autoUpdateExtensions(): TPromise { + const config = this.configurationService.getConfiguration(ConfigurationKey); + + if (!config.autoUpdate) { + return TPromise.as(null); + } + + const action = this.instantiationService.createInstance(UpdateAllAction, UpdateAllAction.ID, UpdateAllAction.LABEL); + + if (!action.enabled) { + return TPromise.as(null); + } + + return action.run(); } canInstall(extension: IExtension): boolean {