@@ -385,6 +385,7 @@ export interface IVSCodeObservableTextDocument extends IObservableDocument {
385
385
kind : 'textDocument' ;
386
386
readonly textDocument : TextDocument ;
387
387
fromOffsetRange ( textDocument : TextDocument , range : OffsetRange ) : Range | undefined ;
388
+ fromRange ( textDocument : TextDocument , range : Range ) : Range | undefined ;
388
389
toOffsetRange ( textDocument : TextDocument , range : Range ) : OffsetRange | undefined ;
389
390
}
390
391
@@ -443,6 +444,10 @@ class VSCodeObservableTextDocument extends AbstractVSCodeObservableDocument impl
443
444
toOffsetRange ( textDocument : TextDocument , range : Range ) : OffsetRange | undefined {
444
445
return new OffsetRange ( textDocument . offsetAt ( range . start ) , textDocument . offsetAt ( range . end ) ) ;
445
446
}
447
+
448
+ fromRange ( _textDocument : TextDocument , range : Range ) : Range | undefined {
449
+ return range ;
450
+ }
446
451
}
447
452
448
453
export interface IVSCodeObservableNotebookDocument extends IObservableDocument {
@@ -458,6 +463,7 @@ export interface IVSCodeObservableNotebookDocument extends IObservableDocument {
458
463
* The range provided could span multiple cells, so it returns an array of tuples containing the cell document and the range within that cell.
459
464
*/
460
465
fromOffsetRange ( range : OffsetRange ) : [ TextDocument , Range ] [ ] ;
466
+ fromRange ( textDocument : TextDocument , range : Range ) : Range | undefined ;
461
467
fromRange ( range : Range ) : [ TextDocument , Range ] [ ] ;
462
468
projectDiagnostics ( cell : TextDocument , diagnostics : readonly Diagnostic [ ] ) : Diagnostic [ ] ;
463
469
}
@@ -495,8 +501,20 @@ class VSCodeObservableNotebookDocument extends AbstractVSCodeObservableDocument
495
501
}
496
502
return undefined ;
497
503
}
498
- fromRange ( range : Range ) : [ TextDocument , Range ] [ ] {
499
- return this . altNotebook . fromAltRange ( range ) . map ( r => [ r [ 0 ] . document , r [ 1 ] ] ) ;
504
+ fromRange ( textDocument : TextDocument , range : Range ) : Range | undefined ;
505
+ fromRange ( range : Range ) : [ TextDocument , Range ] [ ] ;
506
+ fromRange ( arg1 : TextDocument | Range , range ?: Range ) : Range | undefined | [ TextDocument , Range ] [ ] {
507
+ if ( arg1 instanceof Range ) {
508
+ return this . altNotebook . fromAltRange ( arg1 ) . map ( r => [ r [ 0 ] . document , r [ 1 ] ] ) ;
509
+ } else if ( range !== undefined ) {
510
+ const cell = this . altNotebook . getCell ( arg1 ) ;
511
+ if ( ! cell ) {
512
+ return undefined ;
513
+ }
514
+ const results = this . altNotebook . fromAltRange ( range ) ;
515
+ const found = results . find ( r => r [ 0 ] . document === arg1 ) ;
516
+ return found ? found [ 1 ] : undefined ;
517
+ }
500
518
}
501
519
projectDiagnostics ( textDocument : TextDocument , diagnostics : readonly Diagnostic [ ] ) : Diagnostic [ ] {
502
520
const cell = this . altNotebook . getCell ( textDocument ) ;
0 commit comments