Skip to content

Commit

Permalink
Make sure we dispose of marker decorations properly
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Jun 11, 2019
1 parent 674bb67 commit e50e16c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/vs/editor/common/services/markerDecorationsServiceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit e50e16c

Please sign in to comment.