@@ -2819,7 +2819,7 @@ Actual: ${stringify(fullActual)}`);
28192819 }
28202820 }
28212821
2822- private getDocumentHighlightsAtCurrentPosition ( fileNamesToSearch : string [ ] ) {
2822+ private getDocumentHighlightsAtCurrentPosition ( fileNamesToSearch : ReadonlyArray < string > ) {
28232823 const filesToSearch = fileNamesToSearch . map ( name => ts . combinePaths ( this . basePath , name ) ) ;
28242824 return this . languageService . getDocumentHighlights ( this . activeFile . fileName , this . currentCaretPosition , filesToSearch ) ;
28252825 }
@@ -2843,9 +2843,8 @@ Actual: ${stringify(fullActual)}`);
28432843 this . rangesByText ( ) . forEach ( ranges => this . verifyRangesAreDocumentHighlights ( ranges ) ) ;
28442844 }
28452845
2846- public verifyDocumentHighlightsOf ( startRange : Range , ranges : Range [ ] ) {
2847- ts . Debug . assert ( ts . contains ( ranges , startRange ) ) ;
2848- const fileNames = unique ( ranges , range => range . fileName ) ;
2846+ public verifyDocumentHighlightsOf ( startRange : Range , ranges : Range [ ] , options : FourSlashInterface . VerifyDocumentHighlightsOptions | undefined ) {
2847+ const fileNames = options && options . filesToSearch || unique ( ranges , range => range . fileName ) ;
28492848 this . goToRangeStart ( startRange ) ;
28502849 this . verifyDocumentHighlights ( ranges , fileNames ) ;
28512850 }
@@ -2868,7 +2867,7 @@ Actual: ${stringify(fullActual)}`);
28682867 }
28692868 }
28702869
2871- private verifyDocumentHighlights ( expectedRanges : Range [ ] , fileNames : string [ ] = [ this . activeFile . fileName ] ) {
2870+ private verifyDocumentHighlights ( expectedRanges : Range [ ] , fileNames : ReadonlyArray < string > = [ this . activeFile . fileName ] ) {
28722871 const documentHighlights = this . getDocumentHighlightsAtCurrentPosition ( fileNames ) || [ ] ;
28732872
28742873 for ( const dh of documentHighlights ) {
@@ -2880,10 +2879,7 @@ Actual: ${stringify(fullActual)}`);
28802879 for ( const fileName of fileNames ) {
28812880 const expectedRangesInFile = expectedRanges . filter ( r => r . fileName === fileName ) ;
28822881 const highlights = ts . find ( documentHighlights , dh => dh . fileName === fileName ) ;
2883- if ( ! highlights ) {
2884- this . raiseError ( `verifyDocumentHighlights failed - found no highlights in ${ fileName } ` ) ;
2885- }
2886- const spansInFile = highlights . highlightSpans . sort ( ( s1 , s2 ) => s1 . textSpan . start - s2 . textSpan . start ) ;
2882+ const spansInFile = highlights ? highlights . highlightSpans . sort ( ( s1 , s2 ) => s1 . textSpan . start - s2 . textSpan . start ) : [ ] ;
28872883
28882884 if ( expectedRangesInFile . length !== spansInFile . length ) {
28892885 this . raiseError ( `verifyDocumentHighlights failed - In ${ fileName } , expected ${ expectedRangesInFile . length } highlights, got ${ spansInFile . length } ` ) ;
@@ -4272,8 +4268,8 @@ namespace FourSlashInterface {
42724268 this . state . verifyRangesWithSameTextAreDocumentHighlights ( ) ;
42734269 }
42744270
4275- public documentHighlightsOf ( startRange : FourSlash . Range , ranges : FourSlash . Range [ ] ) {
4276- this . state . verifyDocumentHighlightsOf ( startRange , ranges ) ;
4271+ public documentHighlightsOf ( startRange : FourSlash . Range , ranges : FourSlash . Range [ ] , options ?: VerifyDocumentHighlightsOptions ) {
4272+ this . state . verifyDocumentHighlightsOf ( startRange , ranges , options ) ;
42774273 }
42784274
42794275 public noDocumentHighlights ( startRange : FourSlash . Range ) {
@@ -4622,6 +4618,10 @@ namespace FourSlashInterface {
46224618 insertText ?: string ;
46234619 }
46244620
4621+ export interface VerifyDocumentHighlightsOptions {
4622+ filesToSearch ?: ReadonlyArray < string > ;
4623+ }
4624+
46254625 export interface NewContentOptions {
46264626 // Exactly one of these should be defined.
46274627 newFileContent ?: string ;
0 commit comments