@@ -9,33 +9,33 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
99import { ExtHostContext , MainContext , IExtHostContext , MainThreadDecorationsShape , ExtHostDecorationsShape , DecorationData , DecorationRequest } from '../common/extHost.protocol' ;
1010import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers' ;
1111import { IDecorationsService , IDecorationData } from 'vs/workbench/services/decorations/browser/decorations' ;
12- import { values } from 'vs/base/common/collections' ;
1312import { CancellationToken } from 'vs/base/common/cancellation' ;
1413
1514class DecorationRequestsQueue {
1615
1716 private _idPool = 0 ;
18- private _requests : { [ id : number ] : DecorationRequest } = Object . create ( null ) ;
19- private _resolver : { [ id : number ] : ( data : DecorationData ) => any } = Object . create ( null ) ;
17+ private _requests = new Map < number , DecorationRequest > ( ) ;
18+ private _resolver = new Map < number , ( data : DecorationData ) => any > ( ) ;
2019
2120 private _timer : any ;
2221
2322 constructor (
24- private readonly _proxy : ExtHostDecorationsShape
23+ private readonly _proxy : ExtHostDecorationsShape ,
24+ private readonly _handle : number
2525 ) {
2626 //
2727 }
2828
29- enqueue ( handle : number , uri : URI , token : CancellationToken ) : Promise < DecorationData > {
29+ enqueue ( uri : URI , token : CancellationToken ) : Promise < DecorationData > {
3030 const id = ++ this . _idPool ;
3131 const result = new Promise < DecorationData > ( resolve => {
32- this . _requests [ id ] = { id, handle , uri } ;
33- this . _resolver [ id ] = resolve ;
32+ this . _requests . set ( id , { id, uri } ) ;
33+ this . _resolver . set ( id , resolve ) ;
3434 this . _processQueue ( ) ;
3535 } ) ;
3636 token . onCancellationRequested ( ( ) => {
37- delete this . _requests [ id ] ;
38- delete this . _resolver [ id ] ;
37+ this . _requests . delete ( id ) ;
38+ this . _resolver . delete ( id ) ;
3939 } ) ;
4040 return result ;
4141 }
@@ -49,15 +49,15 @@ class DecorationRequestsQueue {
4949 // make request
5050 const requests = this . _requests ;
5151 const resolver = this . _resolver ;
52- this . _proxy . $provideDecorations ( values ( requests ) , CancellationToken . None ) . then ( data => {
52+ this . _proxy . $provideDecorations ( this . _handle , [ ... requests . values ( ) ] , CancellationToken . None ) . then ( data => {
5353 for ( const id in resolver ) {
54- resolver [ id ] ( data [ id ] ) ;
54+ resolver . get ( Number ( id ) ) ! ( data [ Number ( id ) ] ) ;
5555 }
5656 } ) ;
5757
5858 // reset
59- this . _requests = [ ] ;
60- this . _resolver = [ ] ;
59+ this . _requests = new Map ( ) ;
60+ this . _resolver = new Map ( ) ;
6161 this . _timer = undefined ;
6262 } , 0 ) ;
6363 }
@@ -68,14 +68,12 @@ export class MainThreadDecorations implements MainThreadDecorationsShape {
6868
6969 private readonly _provider = new Map < number , [ Emitter < URI [ ] > , IDisposable ] > ( ) ;
7070 private readonly _proxy : ExtHostDecorationsShape ;
71- private readonly _requestQueue : DecorationRequestsQueue ;
7271
7372 constructor (
7473 context : IExtHostContext ,
7574 @IDecorationsService private readonly _decorationsService : IDecorationsService
7675 ) {
7776 this . _proxy = context . getProxy ( ExtHostContext . ExtHostDecorations ) ;
78- this . _requestQueue = new DecorationRequestsQueue ( this . _proxy ) ;
7977 }
8078
8179 dispose ( ) {
@@ -85,23 +83,23 @@ export class MainThreadDecorations implements MainThreadDecorationsShape {
8583
8684 $registerDecorationProvider ( handle : number , label : string ) : void {
8785 const emitter = new Emitter < URI [ ] > ( ) ;
86+ const queue = new DecorationRequestsQueue ( this . _proxy , handle ) ;
8887 const registration = this . _decorationsService . registerDecorationsProvider ( {
8988 label,
9089 onDidChange : emitter . event ,
91- provideDecorations : ( uri , token ) => {
92- return this . _requestQueue . enqueue ( handle , uri , token ) . then ( data => {
93- if ( ! data ) {
94- return undefined ;
95- }
96- const [ weight , bubble , tooltip , letter , themeColor ] = data ;
97- return < IDecorationData > {
98- weight : weight || 0 ,
99- bubble : bubble || false ,
100- color : themeColor && themeColor . id ,
101- tooltip,
102- letter
103- } ;
104- } ) ;
90+ provideDecorations : async ( uri , token ) => {
91+ const data = await queue . enqueue ( uri , token ) ;
92+ if ( ! data ) {
93+ return undefined ;
94+ }
95+ const [ weight , bubble , tooltip , letter , themeColor ] = data ;
96+ return < IDecorationData > {
97+ weight : weight ?? 0 ,
98+ bubble : bubble ?? false ,
99+ color : themeColor ?. id ,
100+ tooltip,
101+ letter
102+ } ;
105103 }
106104 } ) ;
107105 this . _provider . set ( handle , [ emitter , registration ] ) ;
0 commit comments