Skip to content

Commit 0bc10a4

Browse files
committed
Fixes 251268: Errors from task with same owner as extension don't propagate to the EH
1 parent 03394e2 commit 0bc10a4

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

src/vs/monaco.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,7 @@ declare namespace monaco.editor {
14711471
modelVersionId?: number;
14721472
relatedInformation?: IRelatedInformation[];
14731473
tags?: MarkerTag[];
1474+
origin?: string | undefined;
14741475
}
14751476

14761477
/**
@@ -1491,6 +1492,7 @@ declare namespace monaco.editor {
14911492
modelVersionId?: number;
14921493
relatedInformation?: IRelatedInformation[];
14931494
tags?: MarkerTag[];
1495+
origin?: string | undefined;
14941496
}
14951497

14961498
/**

src/vs/platform/markers/common/markerService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export class MarkerService implements IMarkerService {
232232
message, source,
233233
startLineNumber, startColumn, endLineNumber, endColumn,
234234
relatedInformation,
235-
tags,
235+
tags, origin
236236
} = data;
237237

238238
if (!message) {
@@ -258,6 +258,7 @@ export class MarkerService implements IMarkerService {
258258
endColumn,
259259
relatedInformation,
260260
tags,
261+
origin
261262
};
262263
}
263264

src/vs/platform/markers/common/markers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export interface IMarkerData {
118118
modelVersionId?: number;
119119
relatedInformation?: IRelatedInformation[];
120120
tags?: MarkerTag[];
121+
origin?: string | undefined;
121122
}
122123

123124
export interface IResourceMarker {
@@ -139,6 +140,7 @@ export interface IMarker {
139140
modelVersionId?: number;
140141
relatedInformation?: IRelatedInformation[];
141142
tags?: MarkerTag[];
143+
origin?: string | undefined;
142144
}
143145

144146
export interface MarkerStatistics {

src/vs/workbench/api/browser/mainThreadDiagnostics.ts

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { IMarkerService, IMarkerData } from '../../../platform/markers/common/markers.js';
6+
import { IMarkerService, IMarkerData, type IMarker } from '../../../platform/markers/common/markers.js';
77
import { URI, UriComponents } from '../../../base/common/uri.js';
88
import { MainThreadDiagnosticsShape, MainContext, ExtHostDiagnosticsShape, ExtHostContext } from '../common/extHost.protocol.js';
99
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
@@ -18,6 +18,9 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
1818
private readonly _proxy: ExtHostDiagnosticsShape;
1919
private readonly _markerListener: IDisposable;
2020

21+
private static ExtHostCounter: number = 1;
22+
private readonly extHostId: string;
23+
2124
constructor(
2225
extHostContext: IExtHostContext,
2326
@IMarkerService private readonly _markerService: IMarkerService,
@@ -26,12 +29,28 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
2629
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostDiagnostics);
2730

2831
this._markerListener = this._markerService.onMarkerChanged(this._forwardMarkers, this);
32+
this.extHostId = `extHost${MainThreadDiagnostics.ExtHostCounter++}`;
2933
}
3034

3135
dispose(): void {
3236
this._markerListener.dispose();
33-
this._activeOwners.forEach(owner => this._markerService.changeAll(owner, []));
34-
this._activeOwners.clear();
37+
for (const owner of this._activeOwners) {
38+
const markersData: Map<string, { resource: URI; local: IMarker[] }> = new Map();
39+
for (const marker of this._markerService.read({ owner })) {
40+
const resource = marker.resource.toString();
41+
let data = markersData.get(resource);
42+
if (data === undefined) {
43+
data = { resource: marker.resource, local: [] };
44+
markersData.set(resource, data);
45+
}
46+
if (marker.origin !== this.extHostId) {
47+
data.local.push(marker);
48+
}
49+
}
50+
for (const { resource, local } of markersData.values()) {
51+
this._markerService.changeOne(owner, resource, local);
52+
}
53+
}
3554
}
3655

3756
private _forwardMarkers(resources: readonly URI[]): void {
@@ -41,9 +60,9 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
4160
if (allMarkerData.length === 0) {
4261
data.push([resource, []]);
4362
} else {
44-
const forgeinMarkerData = allMarkerData.filter(marker => !this._activeOwners.has(marker.owner));
45-
if (forgeinMarkerData.length > 0) {
46-
data.push([resource, forgeinMarkerData]);
63+
const foreignMarkerData = allMarkerData.filter(marker => marker?.origin !== this.extHostId);
64+
if (foreignMarkerData.length > 0) {
65+
data.push([resource, foreignMarkerData]);
4766
}
4867
}
4968
}
@@ -65,6 +84,9 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
6584
if (marker.code && typeof marker.code !== 'string') {
6685
marker.code.target = URI.revive(marker.code.target);
6786
}
87+
if (marker.origin === undefined) {
88+
marker.origin = this.extHostId;
89+
}
6890
}
6991
}
7092
this._markerService.changeOne(owner, this._uriIdentService.asCanonicalUri(URI.revive(uri)), markers);

0 commit comments

Comments
 (0)