@@ -373,13 +373,21 @@ class MultiDocumentHighlightAdapter {
373
373
374
374
constructor (
375
375
private readonly _documents : ExtHostDocuments ,
376
- private readonly _provider : vscode . MultiDocumentHighlightProvider
376
+ private readonly _provider : vscode . MultiDocumentHighlightProvider ,
377
+ private readonly _logService : ILogService ,
377
378
) { }
378
379
379
380
async provideMultiDocumentHighlights ( resource : URI , position : IPosition , otherResources : URI [ ] , token : CancellationToken ) : Promise < languages . MultiDocumentHighlight [ ] | undefined > {
380
-
381
381
const doc = this . _documents . getDocument ( resource ) ;
382
- const otherDocuments = otherResources . map ( r => this . _documents . getDocument ( r ) ) ;
382
+ const otherDocuments = otherResources . map ( r => {
383
+ try {
384
+ return this . _documents . getDocument ( r ) ;
385
+ } catch ( err ) {
386
+ this . _logService . error ( 'Error: Unable to retrieve document from URI: ' + r + '. Error message: ' + err ) ;
387
+ return undefined ;
388
+ }
389
+ } ) . filter ( doc => doc !== undefined ) ;
390
+
383
391
const pos = typeConvert . Position . to ( position ) ;
384
392
385
393
const value = await this . _provider . provideMultiDocumentHighlights ( doc , pos , otherDocuments , token ) ;
@@ -2436,7 +2444,7 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF
2436
2444
}
2437
2445
2438
2446
registerMultiDocumentHighlightProvider ( extension : IExtensionDescription , selector : vscode . DocumentSelector , provider : vscode . MultiDocumentHighlightProvider ) : vscode . Disposable {
2439
- const handle = this . _addNewAdapter ( new MultiDocumentHighlightAdapter ( this . _documents , provider ) , extension ) ;
2447
+ const handle = this . _addNewAdapter ( new MultiDocumentHighlightAdapter ( this . _documents , provider , this . _logService ) , extension ) ;
2440
2448
this . _proxy . $registerMultiDocumentHighlightProvider ( handle , this . _transformDocumentSelector ( selector , extension ) ) ;
2441
2449
return this . _createDisposable ( handle ) ;
2442
2450
}
0 commit comments