diff --git a/src/vs/base/common/lifecycle.ts b/src/vs/base/common/lifecycle.ts index 35c293adaf1d46c6e75faf4e06ec6385ebf573df..1a17d2a524f5689b6b5f8203ba33f728ace71c9f 100644 --- a/src/vs/base/common/lifecycle.ts +++ b/src/vs/base/common/lifecycle.ts @@ -2,8 +2,11 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + 'use strict'; +import { once } from 'vs/base/common/functional'; + export const empty: IDisposable = Object.freeze({ dispose() { } }); @@ -109,12 +112,12 @@ export abstract class ReferenceCollection { } const { object } = reference; - const dispose = () => { + const dispose = once(() => { if (--reference.counter === 0) { this.destroyReferencedObject(reference.object); delete this.references[key]; } - }; + }); reference.counter++;