5
5
import * as assert from 'assert' ;
6
6
import * as sinon from 'sinon' ;
7
7
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock' ;
8
- import { Match , FileMatch , SearchResult , SearchModel } from 'vs/workbench/contrib/search/common/searchModel' ;
8
+ import { Match , FileMatch , SearchResult , SearchModel , FolderMatch } from 'vs/workbench/contrib/search/common/searchModel' ;
9
9
import { URI } from 'vs/base/common/uri' ;
10
10
import { IFileMatch , TextSearchMatch , OneLineRange , ITextSearchMatch , QueryType } from 'vs/workbench/services/search/common/search' ;
11
11
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
@@ -402,36 +402,36 @@ suite('SearchResult', () => {
402
402
const root3 = testObject . folderMatches ( ) [ 3 ] ;
403
403
404
404
const root0DownstreamFiles = root0 . downstreamFileMatches ( ) ;
405
- assert . deepStrictEqual ( root0DownstreamFiles , root0 . fileMatches ( ) . concat ( root0 . folderMatches ( ) [ 0 ] . fileMatches ( ) ) ) ;
406
- assert . deepStrictEqual ( root0 . folderMatches ( ) [ 0 ] . downstreamFileMatches ( ) , root0 . folderMatches ( ) [ 0 ] . fileMatches ( ) ) ;
407
- assert . deepStrictEqual ( root0 . folderMatches ( ) [ 0 ] . fileMatches ( ) [ 0 ] . parent ( ) , root0 . folderMatches ( ) [ 0 ] ) ;
408
- assert . deepStrictEqual ( root0 . folderMatches ( ) [ 0 ] . parent ( ) , root0 ) ;
409
- assert . deepStrictEqual ( root0 . folderMatches ( ) [ 0 ] . closestRoot , root0 ) ;
405
+ assert . deepStrictEqual ( root0DownstreamFiles , [ ... root0 . fileMatchesIterator ( ) , ... getFolderMatchAtIndex ( root0 , 0 ) . fileMatchesIterator ( ) ] ) ;
406
+ assert . deepStrictEqual ( getFolderMatchAtIndex ( root0 , 0 ) . downstreamFileMatches ( ) , Array . from ( getFolderMatchAtIndex ( root0 , 0 ) . fileMatchesIterator ( ) ) ) ;
407
+ assert . deepStrictEqual ( getFileMatchAtIndex ( getFolderMatchAtIndex ( root0 , 0 ) , 0 ) . parent ( ) , getFolderMatchAtIndex ( root0 , 0 ) ) ;
408
+ assert . deepStrictEqual ( getFolderMatchAtIndex ( root0 , 0 ) . parent ( ) , root0 ) ;
409
+ assert . deepStrictEqual ( getFolderMatchAtIndex ( root0 , 0 ) . closestRoot , root0 ) ;
410
410
root0DownstreamFiles . forEach ( ( e ) => {
411
411
assert . deepStrictEqual ( e . closestRoot , root0 ) ;
412
412
} ) ;
413
413
414
414
const root1DownstreamFiles = root1 . downstreamFileMatches ( ) ;
415
- assert . deepStrictEqual ( root1 . downstreamFileMatches ( ) , root1 . fileMatches ( ) . concat ( root1 . folderMatches ( ) [ 0 ] . fileMatches ( ) ) ) ; // excludes the matches from nested root
416
- assert . deepStrictEqual ( root1 . folderMatches ( ) [ 0 ] . fileMatches ( ) [ 0 ] . parent ( ) , root1 . folderMatches ( ) [ 0 ] ) ;
415
+ assert . deepStrictEqual ( root1 . downstreamFileMatches ( ) , [ ... root1 . fileMatchesIterator ( ) , ... getFolderMatchAtIndex ( root1 , 0 ) . fileMatchesIterator ( ) ] ) ; // excludes the matches from nested root
416
+ assert . deepStrictEqual ( getFileMatchAtIndex ( getFolderMatchAtIndex ( root1 , 0 ) , 0 ) . parent ( ) , getFolderMatchAtIndex ( root1 , 0 ) ) ;
417
417
root1DownstreamFiles . forEach ( ( e ) => {
418
418
assert . deepStrictEqual ( e . closestRoot , root1 ) ;
419
419
} ) ;
420
420
421
421
const root2DownstreamFiles = root2 . downstreamFileMatches ( ) ;
422
- assert . deepStrictEqual ( root2DownstreamFiles , root2 . fileMatches ( ) ) ;
423
- assert . deepStrictEqual ( root2 . fileMatches ( ) [ 0 ] . parent ( ) , root2 ) ;
424
- assert . deepStrictEqual ( root2 . fileMatches ( ) [ 0 ] . closestRoot , root2 ) ;
422
+ assert . deepStrictEqual ( root2DownstreamFiles , Array . from ( root2 . fileMatchesIterator ( ) ) ) ;
423
+ assert . deepStrictEqual ( getFileMatchAtIndex ( root2 , 0 ) . parent ( ) , root2 ) ;
424
+ assert . deepStrictEqual ( getFileMatchAtIndex ( root2 , 0 ) . closestRoot , root2 ) ;
425
425
426
426
427
427
const root3DownstreamFiles = root3 . downstreamFileMatches ( ) ;
428
- const root3Level3Folder = root3 . folderMatches ( ) [ 0 ] . folderMatches ( ) [ 0 ] ;
429
- assert . deepStrictEqual ( root3DownstreamFiles , [ root3 . fileMatches ( ) , ...root3Level3Folder . folderMatches ( ) [ 0 ] . fileMatches ( ) , ...root3Level3Folder . folderMatches ( ) [ 1 ] . fileMatches ( ) ] . flat ( ) ) ;
430
- assert . deepStrictEqual ( root3Level3Folder . downstreamFileMatches ( ) , root3 . folderMatches ( ) [ 0 ] . downstreamFileMatches ( ) ) ;
428
+ const root3Level3Folder = getFolderMatchAtIndex ( getFolderMatchAtIndex ( root3 , 0 ) , 0 ) ;
429
+ assert . deepStrictEqual ( root3DownstreamFiles , [ ... root3 . fileMatchesIterator ( ) , ...getFolderMatchAtIndex ( root3Level3Folder , 0 ) . fileMatchesIterator ( ) , ...getFolderMatchAtIndex ( root3Level3Folder , 1 ) . fileMatchesIterator ( ) ] . flat ( ) ) ;
430
+ assert . deepStrictEqual ( root3Level3Folder . downstreamFileMatches ( ) , getFolderMatchAtIndex ( root3 , 0 ) . downstreamFileMatches ( ) ) ;
431
431
432
- assert . deepStrictEqual ( root3Level3Folder . folderMatches ( ) [ 1 ] . fileMatches ( ) [ 0 ] . parent ( ) , root3Level3Folder . folderMatches ( ) [ 1 ] ) ;
433
- assert . deepStrictEqual ( root3Level3Folder . folderMatches ( ) [ 1 ] . parent ( ) , root3Level3Folder ) ;
434
- assert . deepStrictEqual ( root3Level3Folder . parent ( ) , root3 . folderMatches ( ) [ 0 ] ) ;
432
+ assert . deepStrictEqual ( getFileMatchAtIndex ( getFolderMatchAtIndex ( root3Level3Folder , 1 ) , 0 ) . parent ( ) , getFolderMatchAtIndex ( root3Level3Folder , 1 ) ) ;
433
+ assert . deepStrictEqual ( getFolderMatchAtIndex ( root3Level3Folder , 1 ) . parent ( ) , root3Level3Folder ) ;
434
+ assert . deepStrictEqual ( root3Level3Folder . parent ( ) , getFolderMatchAtIndex ( root3 , 0 ) ) ;
435
435
436
436
root3DownstreamFiles . forEach ( ( e ) => {
437
437
assert . deepStrictEqual ( e . closestRoot , root3 ) ;
@@ -442,7 +442,7 @@ suite('SearchResult', () => {
442
442
const target = sinon . spy ( ) ;
443
443
const testObject = getPopulatedSearchResultForTreeTesting ( ) ;
444
444
445
- const folderMatch = testObject . folderMatches ( ) [ 3 ] . folderMatches ( ) [ 0 ] . folderMatches ( ) [ 0 ] . folderMatches ( ) [ 0 ] ;
445
+ const folderMatch = getFolderMatchAtIndex ( getFolderMatchAtIndex ( getFolderMatchAtIndex ( testObject . folderMatches ( ) [ 3 ] , 0 ) , 0 ) , 0 ) ;
446
446
447
447
const expectedArrayResult = folderMatch . downstreamFileMatches ( ) ;
448
448
@@ -456,7 +456,7 @@ suite('SearchResult', () => {
456
456
const target = sinon . spy ( ) ;
457
457
const testObject = getPopulatedSearchResultForTreeTesting ( ) ;
458
458
459
- const folderMatch = testObject . folderMatches ( ) [ 3 ] . folderMatches ( ) [ 0 ] ;
459
+ const folderMatch = getFolderMatchAtIndex ( testObject . folderMatches ( ) [ 3 ] , 0 ) ;
460
460
461
461
const expectedArrayResult = folderMatch . downstreamFileMatches ( ) ;
462
462
@@ -600,4 +600,12 @@ suite('SearchResult', () => {
600
600
] ) ;
601
601
return testObject ;
602
602
}
603
+
604
+ function getFolderMatchAtIndex ( parent : FolderMatch , index : number ) {
605
+ return Array . from ( parent . folderMatchesIterator ( ) ) [ index ] ;
606
+ }
607
+
608
+ function getFileMatchAtIndex ( parent : FolderMatch , index : number ) {
609
+ return Array . from ( parent . fileMatchesIterator ( ) ) [ index ] ;
610
+ }
603
611
} ) ;
0 commit comments