Fixes 251268: Errors from task with same owner as extension don't propagate to the EH

This commit is contained in:
Dirk Baeumer 2025-07-01 18:17:27 +02:00
parent 03394e2fa7
commit 0bc10a4e46
No known key found for this signature in database
GPG Key ID: DD95715335E91385
4 changed files with 34 additions and 7 deletions

2
src/vs/monaco.d.ts vendored
View File

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

View File

@ -232,7 +232,7 @@ export class MarkerService implements IMarkerService {
message, source,
startLineNumber, startColumn, endLineNumber, endColumn,
relatedInformation,
tags,
tags, origin
} = data;
if (!message) {
@ -258,6 +258,7 @@ export class MarkerService implements IMarkerService {
endColumn,
relatedInformation,
tags,
origin
};
}

View File

@ -118,6 +118,7 @@ export interface IMarkerData {
modelVersionId?: number;
relatedInformation?: IRelatedInformation[];
tags?: MarkerTag[];
origin?: string | undefined;
}
export interface IResourceMarker {
@ -139,6 +140,7 @@ export interface IMarker {
modelVersionId?: number;
relatedInformation?: IRelatedInformation[];
tags?: MarkerTag[];
origin?: string | undefined;
}
export interface MarkerStatistics {

View File

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IMarkerService, IMarkerData } from '../../../platform/markers/common/markers.js';
import { IMarkerService, IMarkerData, type IMarker } from '../../../platform/markers/common/markers.js';
import { URI, UriComponents } from '../../../base/common/uri.js';
import { MainThreadDiagnosticsShape, MainContext, ExtHostDiagnosticsShape, ExtHostContext } from '../common/extHost.protocol.js';
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
@ -18,6 +18,9 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
private readonly _proxy: ExtHostDiagnosticsShape;
private readonly _markerListener: IDisposable;
private static ExtHostCounter: number = 1;
private readonly extHostId: string;
constructor(
extHostContext: IExtHostContext,
@IMarkerService private readonly _markerService: IMarkerService,
@ -26,12 +29,28 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostDiagnostics);
this._markerListener = this._markerService.onMarkerChanged(this._forwardMarkers, this);
this.extHostId = `extHost${MainThreadDiagnostics.ExtHostCounter++}`;
}
dispose(): void {
this._markerListener.dispose();
this._activeOwners.forEach(owner => this._markerService.changeAll(owner, []));
this._activeOwners.clear();
for (const owner of this._activeOwners) {
const markersData: Map<string, { resource: URI; local: IMarker[] }> = new Map();
for (const marker of this._markerService.read({ owner })) {
const resource = marker.resource.toString();
let data = markersData.get(resource);
if (data === undefined) {
data = { resource: marker.resource, local: [] };
markersData.set(resource, data);
}
if (marker.origin !== this.extHostId) {
data.local.push(marker);
}
}
for (const { resource, local } of markersData.values()) {
this._markerService.changeOne(owner, resource, local);
}
}
}
private _forwardMarkers(resources: readonly URI[]): void {
@ -41,9 +60,9 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
if (allMarkerData.length === 0) {
data.push([resource, []]);
} else {
const forgeinMarkerData = allMarkerData.filter(marker => !this._activeOwners.has(marker.owner));
if (forgeinMarkerData.length > 0) {
data.push([resource, forgeinMarkerData]);
const foreignMarkerData = allMarkerData.filter(marker => marker?.origin !== this.extHostId);
if (foreignMarkerData.length > 0) {
data.push([resource, foreignMarkerData]);
}
}
}
@ -65,6 +84,9 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
if (marker.code && typeof marker.code !== 'string') {
marker.code.target = URI.revive(marker.code.target);
}
if (marker.origin === undefined) {
marker.origin = this.extHostId;
}
}
}
this._markerService.changeOne(owner, this._uriIdentService.asCanonicalUri(URI.revive(uri)), markers);