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' ;
10
10
import { IDisposable } from '../../../base/common/lifecycle.js' ;
11
11
import { IUriIdentityService } from '../../../platform/uriIdentity/common/uriIdentity.js' ;
12
+ import { ResourceMap } from '../../../base/common/map.js' ;
12
13
13
14
@extHostNamedCustomer ( MainContext . MainThreadDiagnostics )
14
15
export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
@@ -18,6 +19,9 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
18
19
private readonly _proxy : ExtHostDiagnosticsShape ;
19
20
private readonly _markerListener : IDisposable ;
20
21
22
+ private static ExtHostCounter : number = 1 ;
23
+ private readonly extHostId : string ;
24
+
21
25
constructor (
22
26
extHostContext : IExtHostContext ,
23
27
@IMarkerService private readonly _markerService : IMarkerService ,
@@ -26,11 +30,27 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
26
30
this . _proxy = extHostContext . getProxy ( ExtHostContext . ExtHostDiagnostics ) ;
27
31
28
32
this . _markerListener = this . _markerService . onMarkerChanged ( this . _forwardMarkers , this ) ;
33
+ this . extHostId = `extHost${ MainThreadDiagnostics . ExtHostCounter ++ } ` ;
29
34
}
30
35
31
36
dispose ( ) : void {
32
37
this . _markerListener . dispose ( ) ;
33
- this . _activeOwners . forEach ( owner => this . _markerService . changeAll ( owner , [ ] ) ) ;
38
+ for ( const owner of this . _activeOwners ) {
39
+ const markersData : ResourceMap < IMarker [ ] > = new ResourceMap < IMarker [ ] > ( ) ;
40
+ for ( const marker of this . _markerService . read ( { owner } ) ) {
41
+ let data = markersData . get ( marker . resource ) ;
42
+ if ( data === undefined ) {
43
+ data = [ ] ;
44
+ markersData . set ( marker . resource , data ) ;
45
+ }
46
+ if ( marker . origin !== this . extHostId ) {
47
+ data . push ( marker ) ;
48
+ }
49
+ }
50
+ for ( const [ resource , local ] of markersData . entries ( ) ) {
51
+ this . _markerService . changeOne ( owner , resource , local ) ;
52
+ }
53
+ }
34
54
this . _activeOwners . clear ( ) ;
35
55
}
36
56
@@ -41,9 +61,9 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
41
61
if ( allMarkerData . length === 0 ) {
42
62
data . push ( [ resource , [ ] ] ) ;
43
63
} else {
44
- const forgeinMarkerData = allMarkerData . filter ( marker => ! this . _activeOwners . has ( marker . owner ) ) ;
45
- if ( forgeinMarkerData . length > 0 ) {
46
- data . push ( [ resource , forgeinMarkerData ] ) ;
64
+ const foreignMarkerData = allMarkerData . filter ( marker => marker ?. origin !== this . extHostId ) ;
65
+ if ( foreignMarkerData . length > 0 ) {
66
+ data . push ( [ resource , foreignMarkerData ] ) ;
47
67
}
48
68
}
49
69
}
@@ -65,6 +85,9 @@ export class MainThreadDiagnostics implements MainThreadDiagnosticsShape {
65
85
if ( marker . code && typeof marker . code !== 'string' ) {
66
86
marker . code . target = URI . revive ( marker . code . target ) ;
67
87
}
88
+ if ( marker . origin === undefined ) {
89
+ marker . origin = this . extHostId ;
90
+ }
68
91
}
69
92
}
70
93
this . _markerService . changeOne ( owner , this . _uriIdentService . asCanonicalUri ( URI . revive ( uri ) ) , markers ) ;
0 commit comments