Make sure we dispose of marker decorations properly

This commit is contained in:
Matt Bierner 2019-06-10 17:44:34 -07:00
parent 674bb6700b
commit e50e16c9ec

View file

@ -63,10 +63,10 @@ export class MarkerDecorationsService extends Disposable implements IMarkerDecor
_serviceBrand: any;
private readonly _onDidChangeMarker = new Emitter<ITextModel>();
private readonly _onDidChangeMarker = this._register(new Emitter<ITextModel>());
readonly onDidChangeMarker: Event<ITextModel> = this._onDidChangeMarker.event;
private readonly _markerDecorations: Map<string, MarkerDecorations> = new Map<string, MarkerDecorations>();
private readonly _markerDecorations = new Map<string, MarkerDecorations>();
constructor(
@IModelService modelService: IModelService,
@ -79,6 +79,14 @@ export class MarkerDecorationsService extends Disposable implements IMarkerDecor
this._register(this._markerService.onMarkerChanged(this._handleMarkerChange, this));
}
dispose() {
super.dispose();
for (const [, decorations] of this._markerDecorations) {
decorations.dispose();
}
this._markerDecorations.clear();
}
getMarker(model: ITextModel, decoration: IModelDecoration): IMarker | null {
const markerDecorations = this._markerDecorations.get(MODEL_ID(model.uri));
return markerDecorations ? withUndefinedAsNull(markerDecorations.getMarker(decoration)) : null;