diff --git a/src/vs/workbench/api/node/extHostProgress.ts b/src/vs/workbench/api/node/extHostProgress.ts index f4a17349909c37fa580ef845ea2523b71a09c74f..45eb184944a7dfffae5473f42fe72e7d774e5b39 100644 --- a/src/vs/workbench/api/node/extHostProgress.ts +++ b/src/vs/workbench/api/node/extHostProgress.ts @@ -11,7 +11,6 @@ import { IExtensionDescription } from 'vs/workbench/services/extensions/common/e import { Progress } from 'vs/platform/progress/common/progress'; import { localize } from 'vs/nls'; import { CancellationTokenSource, CancellationToken } from 'vs/base/common/cancellation'; -import { debounce } from 'vs/base/common/decorators'; import { IProgressStep } from 'vs/workbench/services/progress/common/progress'; export class ExtHostProgress implements ExtHostProgressShape { @@ -69,22 +68,37 @@ export class ExtHostProgress implements ExtHostProgressShape { } } -function mergeProgress(result: IProgressStep, currentValue: IProgressStep): IProgressStep { - result.message = currentValue.message; - if (typeof currentValue.increment === 'number') { - result.increment = currentValue.increment; - } - - return result; -} - class ProgressCallback extends Progress { + private throttledProgressStep: IProgressStep; + constructor(private _proxy: MainThreadProgressShape, private _handle: number) { super(p => this.throttledReport(p)); } - @debounce(100, (result: IProgressStep, currentValue: IProgressStep) => mergeProgress(result, currentValue), () => Object.create(null)) - throttledReport(p: IProgressStep): void { - this._proxy.$progressReport(this._handle, p); + private throttledReport(p: IProgressStep): void { + + // Throttle progress over the duration of 100ms + if (!this.throttledProgressStep) { + this.throttledProgressStep = p; + + setTimeout(() => { + this._proxy.$progressReport(this._handle, this.throttledProgressStep); + + this.throttledProgressStep = void 0; + }, 100); + } + + // If throttled, merge the progress step into the existing one + else { + this.throttledProgressStep.message = p.message; + + if (typeof p.increment === 'number') { + if (typeof this.throttledProgressStep.increment === 'number') { + this.throttledProgressStep.increment += p.increment; + } else { + this.throttledProgressStep.increment = p.increment; + } + } + } } -} \ No newline at end of file +}