3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- import { IMarkerService , IMarkerData } from '../../../platform/markers/common/markers.js' ;
6
+ import { IMarkerService , IMarkerData , type IMarker } from '../../../platform/markers/common/markers.js' ;
7
7
import { URI , UriComponents } from '../../../base/common/uri.js' ;
8
8
import { MainThreadDiagnosticsShape , MainContext , ExtHostDiagnosticsShape , ExtHostContext } from '../common/extHost.protocol.js' ;
9
9
import { extHostNamedCustomer , IExtHostContext } from '../../services/extensions/common/extHostCustomers.js' ;
@@ -18,6 +18,9 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
18
18
private readonly _proxy : ExtHostDiagnosticsShape ;
19
19
private readonly _markerListener : IDisposable ;
20
20
21
+ private static ExtHostCounter : number = 1 ;
22
+ private readonly extHostId : string ;
23
+
21
24
constructor (
22
25
extHostContext : IExtHostContext ,
23
26
@IMarkerService private readonly _markerService : IMarkerService ,
@@ -26,12 +29,28 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
26
29
this . _proxy = extHostContext . getProxy ( ExtHostContext . ExtHostDiagnostics ) ;
27
30
28
31
this . _markerListener = this . _markerService . onMarkerChanged ( this . _forwardMarkers , this ) ;
32
+ this . extHostId = `extHost${ MainThreadDiagnostics . ExtHostCounter ++ } ` ;
29
33
}
30
34
31
35
dispose ( ) : void {
32
36
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
+ }
35
54
}
36
55
37
56
private _forwardMarkers ( resources : readonly URI [ ] ) : void {
@@ -41,9 +60,9 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
41
60
if ( allMarkerData . length === 0 ) {
42
61
data . push ( [ resource , [ ] ] ) ;
43
62
} 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 ] ) ;
47
66
}
48
67
}
49
68
}
@@ -65,6 +84,9 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
65
84
if ( marker . code && typeof marker . code !== 'string' ) {
66
85
marker . code . target = URI . revive ( marker . code . target ) ;
67
86
}
87
+ if ( marker . origin === undefined ) {
88
+ marker . origin = this . extHostId ;
89
+ }
68
90
}
69
91
}
70
92
this . _markerService . changeOne ( owner , this . _uriIdentService . asCanonicalUri ( URI . revive ( uri ) ) , markers ) ;
0 commit comments