Change:
private _updateDecorations(markerDecorations: MarkerDecorations): void { // Limit to the first 500 errors/warnings const markers = this._markerService.read({ resource: markerDecorations.model.uri, take: 500 }); <del> const newModelDecorations: IModelDeltaDecoration[] = markers.map((marker) => { </del> <ins> if (markerDecorations.update(markers)) { this._onDidChangeMarker.fire(markerDecorations.model); } } } class MarkerDecorations extends Disposable { private readonly _map = new BidirectionalMap<IMarker, /*decoration id*/string>(); constructor( readonly model: ITextModel ) { super(); this._register(toDisposable(() => { this.model.deltaDecorations([...this._map.values()], []); this._map.clear(); })); } public update(markers: IMarker[]): boolean { // We use the fact that marker instances are not recreated when different owners // update. So we can compare references to find out what changed since the last update. const { added, removed } = diffSets(new Set(this._map.keys()), new Set(markers)); if (added.length === 0 && removed.length === 0) { return false; } const oldIds: string[] = removed.map(marker => this._map.get(marker)!); const newDecorations: IModelDeltaDecoration[] = added.map(marker => { </ins> return { <del> range: this._createDecorationRange(markerDecorations.model, marker), </del> <ins> range: this._createDecorationRange(this.model, marker), </ins> options: this._createDecorationOption(marker) }; }); <del> if (markerDecorations.update(markers, newModelDecorations)) { this._onDidChangeMarker.fire(markerDecorations.model); </del> <ins> const ids = this.model.deltaDecorations(oldIds, newDecorations); for (const removedMarker of removed) { this._map.delete(removedMarker); </ins> } <ins> for (let index = 0; index < ids.length; index++) { this._map.set(added[index], ids[index]); } return true; } getMarker(decoration: IModelDecoration): IMarker | undefined { return this._map.getKey(decoration.id); } getMarkers(): [Range, IMarker][] { const res: [Range, IMarker][] = []; this._map.forEach((id, marker) => { const range = this.model.getDecorationRange(id); if (range) { res.push([range, marker]); } }); return res; </ins> } private _createDecorationRange(model: ITextModel, rawMarker: IMarker): Range {

Discussion:
I wonder why all of line 14 becomes gray (i.e. unused) after I remove line 13. I guess this is because the decorations of line 13 get applied to line 14 which becomes line 13. I think we can improve this by listening to text edits and updating the cache accordingly - when a line is deleted, its decorations should be deleted too and not just applied to whatever lines becomes the deleted line. ! Another example: !
This is for TypeScript: ! And this for JSON: ! This indicates that this is indeed a problem of TypeScript, and not diagnostics in general (
how about a small TS repro sample?
!
Looks pretty normal here. Also just checked with that TypeScript uses plain diagnostics. Can be because of another setting/feature that interfers here? https://user-
Interesting. It also happens when I reset all my settings, but it only happens in the VS Code repository (but there every single time)...
I can't reproduce any problems when there is a single diagnostic present. Having a single diagnostic updates great: Using the following sample in an untitled file in the repo: ts /
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See in the project root for license information. *
-------------/ const x = 3; ('' x + '' / 3); https://user- However, when removing the trailing such that also creates a diagnostic, I can see that the squiggle gets out of sync. I suspect that is constantly updating its diagnostic, while is not. Most likely, the fact that updates its diagnostic results in firing and the re-reading the markers from it and re-applying them. The marker goes to the right spot since it was newly refreshed by , but the marker goes to its original spot since didn't update it: https://user- To tackle this and only update the decorations for a certain diagnostics provider, the events would need to be more fine-grained and then could selectively update decorations by owner.
That's a nice find!
A cheap solution here would be for markers to record a model version id at the time they are set in the marker service. The could then read the markers and recreate squiggles only for the markers which are "fresh".
Yeah, that will work but there is no guarantee for this - since markers can be pushed for any resource.

Tho, in this case it will help
adds (which can be undefined tho)
Added the version to markers, un-assigning myself to leave the remaining work to