ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / workbench / contrib / search / test / browser / searchResult.test.ts 745 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
import assert from 'assert' ;
import * as sinon from 'sinon' ;
import { TestInstantiationService } from '../../../../../platform/instantiation/test/common/instantiationServiceMock.js' ;
import { SearchModelImpl } from '../../browser/searchTreeModel/searchModel.js' ;
import { URI } from '../../../../../base/common/uri.js' ;
import { IFileMatch, TextSearchMatch, OneLineRange, ITextSearchMatch, QueryType } from '../../../../services/search/common/search.js' ;
import { ITelemetryService } from '../../../../../platform/telemetry/common/telemetry.js'
NullTelemetryService
Range
IConfigurationService
TestConfigurationService
ModelService
IModelService
IReplaceService
IThemeService
TestThemeService
IUriIdentityService
UriIdentityService
FileService
ILogService NullLogService
ILabelService
MockLabelService
INotebookEditorService
IEditorGroupsService
TestEditorGroupsService TestEditorService
NotebookEditorWidgetService
ICellViewModel
CellKind
addToSearchResult createFileUriFromPathFromRoot getRootName
INotebookCellMatchWithModel INotebookFileMatchWithModel
IContextKeyService
MockContextKeyService
IEditorService
ensureNoDisposablesAreLeakedInTestSuite
CellMatch NotebookCompatibleFileMatch
INotebookFileInstanceMatch
ISearchResult ISearchTreeFolderMatch isSearchTreeFolderMatchNoRoot
FolderMatchImpl
SearchResultImpl
MatchImpl
lineOneRange
instantiationService TestInstantiationService
store
instantiationService
instantiationService ITelemetryService NullTelemetryService
instantiationService IModelService instantiationService
instantiationService INotebookEditorService instantiationService
fileService
store fileService
uriIdentityService fileService
store uriIdentityService
instantiationService IUriIdentityService uriIdentityService
instantiationService IReplaceService
instantiationService IReplaceService
instantiationService ILabelService
instantiationService ILogService
instantiationService
fileMatch
lineMatch fileMatch
assert lineMatch
assert lineMatch startLineNumber
assert lineMatch endLineNumber
assert lineMatch startColumn
assert lineMatch endColumn
assert lineMatch
assert lineMatch
assert lineMatch
fileMatch
lineMatch fileMatch
fileMatch lineMatch
assert fileMatch length
fileMatch
assert fileMatch length
assert fileMatch resource
assert fileMatch
fileMatch
assert fileMatch length
assert fileMatch resource
assert fileMatch
testObject
testObject testObject
assert testObject testObject
testObject
target testObject
testObject target
testObject target
assert testObject
testObject
target testObject
testObject target
assert testObject target
testObject
testObject testObject
assert testObject testObject
testObject
testObject testObject
testObject
assert testObject
testObject
testObject
assert testObject
searchModel instantiationService SearchModelImpl
store searchModel
searchResult instantiationService SearchResultImpl searchModel
store searchResult
fileMatch searchResult
lineMatch fileMatch
lineMatch fileMatch
fileMatch searchResult
testObject
target
lineOneRange
testObject target
assert testObject
actual testObject
assert actual length
assert actual resource
actuaMatches actual
assert actuaMatches length
assert actuaMatches
assert actuaMatches
assert actuaMatches
assert actuaMatches
assert actuaMatches
assert actuaMatches
testObject
target
lineOneRange
testObject target
assert testObject
actual testObject
assert actual length
assert actual resource
actuaMatches actual
assert actuaMatches length
assert actuaMatches
assert actuaMatches
assert actuaMatches
assert actuaMatches
actuaMatches actual
assert actuaMatches length
assert actuaMatches
assert actuaMatches
testObject
cell1 cellKind CellKind Code ICellViewModel
cell2 cellKind CellKind Code ICellViewModel
sinon CellMatch prototype
addFileMatch sinon FolderMatchImpl prototype
fileMatch1
cell cell1
index
contentResults
webviewResults
lineOneRange
fileMatch2
cell cell2
index
contentResults
webviewResults
lineOneRange
target fileMatch1 fileMatch2
testObject target
assert testObject
assert fileMatch1 cellResults contentResults addFileMatch args INotebookFileMatchWithModel cellResults contentResults
assert fileMatch1 cellResults webviewResults addFileMatch args INotebookFileMatchWithModel cellResults webviewResults
assert fileMatch2 cellResults contentResults addFileMatch args INotebookFileMatchWithModel cellResults contentResults
assert fileMatch2 cellResults webviewResults addFileMatch args INotebookFileMatchWithModel cellResults webviewResults
target1 sinon
target2 sinon
testObject
testObject
lineOneRange
lineOneRange
store testObject target1
store testObject target2
testObject
assert testObject
assert target1 calledOnce
assert target2 calledOnce
target sinon
testObject
testObject
lineOneRange
objectToRemove testObject
store testObject target
testObject objectToRemove
assert target calledOnce
assert elements objectToRemove removed target args
target sinon
testObject
testObject
lineOneRange
lineOneRange
arrayToRemove testObject
store testObject target
testObject arrayToRemove
assert target calledOnce
assert elements arrayToRemove removed target args
testObject
testObject
lineOneRange
target testObject
matchToRemove target
target matchToRemove
assert testObject
target matchToRemove
assert testObject
assert target testObject
voidPromise
instantiationService IReplaceService voidPromise
testObject
testObject
lineOneRange
testObject testObject
voidPromise assert testObject
target sinon
voidPromise
instantiationService IReplaceService voidPromise
testObject
testObject
lineOneRange
store testObject target
objectToRemove testObject
testObject objectToRemove
voidPromise
assert target calledOnce
assert elements objectToRemove removed target args
voidPromise
instantiationService IReplaceService voidPromise
testObject
testObject
lineOneRange
lineOneRange
testObject
voidPromise assert testObject
target sinon
testObject
folderMatch testObject
fileMatch testObject
match testObject
arrayToRemove folderMatch fileMatch match
expectedArrayResult folderMatch fileMatch match
store testObject target
testObject arrayToRemove
assert target calledOnce
assert elements expectedArrayResult removed added target args
target sinon
testObject
testObject query
type QueryType Text
contentPattern pattern
folderQueries
folder
testObject
lineOneRange
testObject
lineOneRange
folderMatches testObject
assert folderMatches length
otherFilesMatch folderMatches fm fm
assert otherFilesMatch
assert otherFilesMatch length
store testObject target
testObject otherFilesMatch
assert target calledOnce
assert otherFilesMatch length
testObject
disposeSpies testObject folderMatch sinon folderMatch
folder
testObject query
type QueryType Text
contentPattern pattern
folderQueries folder folder
testObject
testObject
assert disposeSpies spy spy callCount
replaceSpy sinon
instantiationService IReplaceService arg
arg
arg
arg
target sinon
testObject
folderMatch testObject
fileMatch testObject
match testObject
firstExpectedMatch folderMatch
arrayToRemove folderMatch fileMatch match
store testObject target
testObject arrayToRemove
assert target calledOnce
sinon assert replaceSpy
sinon assert replaceSpy firstCall firstExpectedMatch
sinon assert replaceSpy secondCall fileMatch
sinon assert replaceSpy thirdCall match
testObject
root0 testObject
root1 testObject
root2 testObject
root3 testObject
root0DownstreamFiles root0
assert root0DownstreamFiles root0 root0
assert root0 root0
assert root0 root0
assert root0 root0
assert root0 FolderMatchImpl closestRoot root0
root0DownstreamFiles e
assert e closestRoot root0
root1DownstreamFiles root1
assert root1 root1 root1
assert root1 root1
root1DownstreamFiles e
assert e closestRoot root1
root2DownstreamFiles root2
assert root2DownstreamFiles root2
assert root2 root2
assert root2 closestRoot root2
root3DownstreamFiles root3
root3Level3Folder root3
assert root3DownstreamFiles root3 root3Level3Folder root3Level3Folder
assert root3Level3Folder root3
assert root3Level3Folder root3Level3Folder
assert root3Level3Folder root3Level3Folder
assert root3Level3Folder root3
root3DownstreamFiles e
assert e closestRoot root3
target sinon
testObject
folderMatch testObject
expectedArrayResult folderMatch
store testObject target
testObject folderMatch
assert target calledOnce
assert elements expectedArrayResult removed added clearingAll target args
target sinon
testObject
folderMatch testObject
expectedArrayResult folderMatch
store testObject target
testObject folderMatch
assert elements expectedArrayResult removed added target args
path searchResult ISearchResult lineMatches ITextSearchMatch INotebookFileInstanceMatch
searchResult
searchResult
rawMatch IFileMatch
resource path
results lineMatches
root searchResult
fileMatch instantiationService NotebookCompatibleFileMatch
pattern
root rawMatch
fileMatch
store fileMatch
fileMatch
ISearchResult
searchModel instantiationService SearchModelImpl
store searchModel
searchModel searchResult query
type QueryType Text folderQueries folder contentPattern
pattern
searchModel searchResult
resource results ITextSearchMatch IFileMatch
resource resource results
resource cellMatches INotebookCellMatchWithModel INotebookFileMatchWithModel
resource resource
cellResults cellMatches
instantiationService TestInstantiationService IModelService
instantiationService IThemeService
config
config searchOnType
instantiationService IConfigurationService config
modelService instantiationService ModelService
store modelService
modelService
instantiationService TestInstantiationService INotebookEditorService
instantiationService IEditorGroupsService
instantiationService IContextKeyService
instantiationService IEditorService store
notebookEditorWidgetService instantiationService NotebookEditorWidgetService
store notebookEditorWidgetService
notebookEditorWidgetService
testObject
testObject query
type QueryType Text
contentPattern pattern
folderQueries
folder
folder
testObject
lineOneRange lineOneRange
lineOneRange
lineOneRange lineOneRange
testObject
testObject
testObject query
type QueryType Text
contentPattern pattern
folderQueries
folder
folder
folder
folder
testObject
lineOneRange lineOneRange
lineOneRange lineOneRange
lineOneRange
lineOneRange lineOneRange
lineOneRange
lineOneRange
lineOneRange lineOneRange
lineOneRange lineOneRange
lineOneRange lineOneRange
testObject
parent ISearchTreeFolderMatch index
parent index
parent ISearchTreeFolderMatch index
parent index
;
import
{
}
from
'../../../../../platform/telemetry/common/telemetryUtils.js'
;
import
{
}
from
'../../../../../editor/common/core/range.js'
;
import
{
}
from
'../../../../../platform/configuration/common/configuration.js'
;
import
{
}
from
'../../../../../platform/configuration/test/common/testConfigurationService.js'
;
import
{
}
from
'../../../../../editor/common/services/modelService.js'
;
import
{
}
from
'../../../../../editor/common/services/model.js'
;
import
{
}
from
'../../browser/replace.js'
;
import
{
}
from
'../../../../../platform/theme/common/themeService.js'
;
import
{
}
from
'../../../../../platform/theme/test/common/testThemeService.js'
;
import
{
}
from
'../../../../../platform/uriIdentity/common/uriIdentity.js'
;
import
{
}
from
'../../../../../platform/uriIdentity/common/uriIdentityService.js'
;
import
{
}
from
'../../../../../platform/files/common/fileService.js'
;
import
{
,
}
from
'../../../../../platform/log/common/log.js'
;
import
{
}
from
'../../../../../platform/label/common/label.js'
;
import
{
}
from
'../../../../services/label/test/common/mockLabelService.js'
;
import
{
}
from
'../../../notebook/browser/services/notebookEditorService.js'
;
import
{
}
from
'../../../../services/editor/common/editorGroupsService.js'
;
import
{
,
}
from
'../../../../test/browser/workbenchTestServices.js'
;
import
{
}
from
'../../../notebook/browser/services/notebookEditorServiceImpl.js'
;
import
{
}
from
'../../../notebook/browser/notebookBrowser.js'
;
import
{
}
from
'../../../notebook/common/notebookCommon.js'
;
import
{
,
,
}
from
'./searchTestCommon.js'
;
import
{
,
}
from
'../../browser/notebookSearch/searchNotebookHelpers.js'
;
import
{
}
from
'../../../../../platform/contextkey/common/contextkey.js'
;
import
{
}
from
'../../../../../platform/keybinding/test/common/mockKeybindingService.js'
;
import
{
}
from
'../../../../services/editor/common/editorService.js'
;
import
{
}
from
'../../../../../base/test/common/utils.js'
;
import
{
,
}
from
'../../browser/notebookSearch/notebookSearchModel.js'
;
import
{
}
from
'../../browser/notebookSearch/notebookSearchModelBase.js'
;
import
{
,
,
,
MATCH_PREFIX
}
from
'../../browser/searchTreeModel/searchTreeCommon.js'
;
import
{
}
from
'../../browser/searchTreeModel/folderMatch.js'
;
import
{
}
from
'../../browser/searchTreeModel/searchResult.js'
;
import
{
}
from
'../../browser/searchTreeModel/match.js'
;
const
=
new
OneLineRange
(
1
,
0
,
1
)
;
suite
(
'SearchResult'
,
(
)
=>
{
let
:
;
const
=
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
setup
(
(
)
=>
{
=
new
TestInstantiationService
(
)
;
.
stub
(
,
)
;
.
stub
(
,
stubModelService
(
)
)
;
.
stub
(
,
stubNotebookEditorService
(
)
)
;
const
=
new
FileService
(
new
NullLogService
(
)
)
;
.
add
(
)
;
const
=
new
UriIdentityService
(
)
;
.
add
(
)
;
.
stub
(
,
)
;
.
stubPromise
(
,
{
}
)
;
.
stub
(
,
'replace'
,
(
)
=>
Promise
.
resolve
(
null
)
)
;
.
stub
(
,
new
MockLabelService
(
)
)
;
.
stub
(
,
new
NullLogService
(
)
)
;
}
)
;
teardown
(
(
)
=>
{
.
dispose
(
)
;
}
)
;
test
(
'Line Match'
,
function
(
)
{
const
=
aFileMatch
(
'folder/file.txt'
,
null
!
)
;
const
=
new
MatchImpl
(
,
[
'0 foo bar'
]
,
new
OneLineRange
(
0
,
2
,
5
)
,
new
OneLineRange
(
1
,
0
,
5
)
,
false
)
;
.
strictEqual
(
.
text
(
)
,
'0 foo bar'
)
;
.
strictEqual
(
.
range
(
)
.
,
2
)
;
.
strictEqual
(
.
range
(
)
.
,
2
)
;
.
strictEqual
(
.
range
(
)
.
,
1
)
;
.
strictEqual
(
.
range
(
)
.
,
6
)
;
.
strictEqual
(
.
id
(
)
,
MATCH_PREFIX
+
'file:///folder/file.txt>[2,1 -> 2,6]foo'
)
;
.
strictEqual
(
.
fullMatchText
(
)
,
'foo'
)
;
.
strictEqual
(
.
fullMatchText
(
true
)
,
'0 foo bar'
)
;
}
)
;
test
(
'Line Match - Remove'
,
function
(
)
{
const
=
aFileMatch
(
'folder/file.txt'
,
aSearchResult
(
)
,
new
TextSearchMatch
(
'foo bar'
,
new
OneLineRange
(
1
,
0
,
3
)
)
)
;
const
=
.
matches
(
)
[
0
]
;
.
remove
(
)
;
.
strictEqual
(
.
matches
(
)
.
,
0
)
;
}
)
;
test
(
'File Match'
,
function
(
)
{
let
=
aFileMatch
(
'folder/file.txt'
,
aSearchResult
(
)
)
;
.
strictEqual
(
.
matches
(
)
.
,
0
)
;
.
strictEqual
(
.
.
toString
(
)
,
'file:///folder/file.txt'
)
;
.
strictEqual
(
.
name
(
)
,
'file.txt'
)
;
=
aFileMatch
(
'file.txt'
,
aSearchResult
(
)
)
;
.
strictEqual
(
.
matches
(
)
.
,
0
)
;
.
strictEqual
(
.
.
toString
(
)
,
'file:///file.txt'
)
;
.
strictEqual
(
.
name
(
)
,
'file.txt'
)
;
}
)
;
test
(
'File Match: Select an existing match'
,
function
(
)
{
const
=
aFileMatch
(
'folder/file.txt'
,
aSearchResult
(
)
,
new
TextSearchMatch
(
'foo'
,
new
OneLineRange
(
1
,
0
,
3
)
)
,
new
TextSearchMatch
(
'bar'
,
new
OneLineRange
(
1
,
5
,
3
)
)
)
;
.
setSelectedMatch
(
.
matches
(
)
[
0
]
)
;
.
strictEqual
(
.
matches
(
)
[
0
]
,
.
getSelectedMatch
(
)
)
;
}
)
;
test
(
'File Match: Select non existing match'
,
function
(
)
{
const
=
aFileMatch
(
'folder/file.txt'
,
aSearchResult
(
)
,
new
TextSearchMatch
(
'foo'
,
new
OneLineRange
(
1
,
0
,
3
)
)
,
new
TextSearchMatch
(
'bar'
,
new
OneLineRange
(
1
,
5
,
3
)
)
)
;
const
=
.
matches
(
)
[
0
]
;
.
remove
(
)
;
.
setSelectedMatch
(
)
;
.
strictEqual
(
.
getSelectedMatch
(
)
,
null
)
;
}
)
;
test
(
'File Match: isSelected return true for selected match'
,
function
(
)
{
const
=
aFileMatch
(
'folder/file.txt'
,
aSearchResult
(
)
,
new
TextSearchMatch
(
'foo'
,
new
OneLineRange
(
1
,
0
,
3
)
)
,
new
TextSearchMatch
(
'bar'
,
new
OneLineRange
(
1
,
5
,
3
)
)
)
;
const
=
.
matches
(
)
[
0
]
;
.
setSelectedMatch
(
)
;
.
ok
(
.
isMatchSelected
(
)
)
;
}
)
;
test
(
'File Match: isSelected return false for un-selected match'
,
function
(
)
{
const
=
aFileMatch
(
'folder/file.txt'
,
aSearchResult
(
)
,
new
TextSearchMatch
(
'foo'
,
new
OneLineRange
(
1
,
0
,
3
)
)
,
new
TextSearchMatch
(
'bar'
,
new
OneLineRange
(
1
,
5
,
3
)
)
)
;
.
setSelectedMatch
(
.
matches
(
)
[
0
]
)
;
.
ok
(
!
.
isMatchSelected
(
.
matches
(
)
[
1
]
)
)
;
}
)
;
test
(
'File Match: unselect'
,
function
(
)
{
const
=
aFileMatch
(
'folder/file.txt'
,
aSearchResult
(
)
,
new
TextSearchMatch
(
'foo'
,
new
OneLineRange
(
1
,
0
,
3
)
)
,
new
TextSearchMatch
(
'bar'
,
new
OneLineRange
(
1
,
5
,
3
)
)
)
;
.
setSelectedMatch
(
.
matches
(
)
[
0
]
)
;
.
setSelectedMatch
(
null
)
;
.
strictEqual
(
null
,
.
getSelectedMatch
(
)
)
;
}
)
;
test
(
'File Match: unselect when not selected'
,
function
(
)
{
const
=
aFileMatch
(
'folder/file.txt'
,
aSearchResult
(
)
,
new
TextSearchMatch
(
'foo'
,
new
OneLineRange
(
1
,
0
,
3
)
)
,
new
TextSearchMatch
(
'bar'
,
new
OneLineRange
(
1
,
5
,
3
)
)
)
;
.
setSelectedMatch
(
null
)
;
.
strictEqual
(
null
,
.
getSelectedMatch
(
)
)
;
}
)
;
test
(
'Match -> FileMatch -> SearchResult hierarchy exists'
,
function
(
)
{
const
=
.
createInstance
(
)
;
.
add
(
)
;
const
=
.
createInstance
(
,
)
;
.
add
(
)
;
const
=
aFileMatch
(
'far/boo'
,
)
;
const
=
new
MatchImpl
(
,
[
'foo bar'
]
,
new
OneLineRange
(
0
,
0
,
3
)
,
new
OneLineRange
(
1
,
0
,
3
)
,
false
)
;
assert
(
.
parent
(
)
===
)
;
assert
(
.
parent
(
)
===
.
folderMatches
(
)
[
0
]
)
;
}
)
;
test
(
'Adding a raw match will add a file match with line matches'
,
function
(
)
{
const
=
aSearchResult
(
)
;
const
=
[
aRawMatch
(
'/1'
,
new
TextSearchMatch
(
'preview 1'
,
new
OneLineRange
(
1
,
1
,
4
)
)
,
new
TextSearchMatch
(
'preview 1'
,
new
OneLineRange
(
1
,
4
,
11
)
)
,
new
TextSearchMatch
(
'preview 2'
,
)
)
]
;
addToSearchResult
(
,
)
;
.
strictEqual
(
3
,
.
count
(
)
)
;
const
=
.
matches
(
)
;
.
strictEqual
(
1
,
.
)
;
.
strictEqual
(
URI
.
file
(
` ${ getRootName ( ) } /1 `
)
.
toString
(
)
,
[
0
]
.
.
toString
(
)
)
;
const
=
[
0
]
.
matches
(
)
;
.
strictEqual
(
3
,
.
)
;
.
strictEqual
(
'preview 1'
,
[
0
]
.
text
(
)
)
;
.
ok
(
new
Range
(
2
,
2
,
2
,
5
)
.
equalsRange
(
[
0
]
.
range
(
)
)
)
;
.
strictEqual
(
'preview 1'
,
[
1
]
.
text
(
)
)
;
.
ok
(
new
Range
(
2
,
5
,
2
,
12
)
.
equalsRange
(
[
1
]
.
range
(
)
)
)
;
.
strictEqual
(
'preview 2'
,
[
2
]
.
text
(
)
)
;
.
ok
(
new
Range
(
2
,
1
,
2
,
2
)
.
equalsRange
(
[
2
]
.
range
(
)
)
)
;
}
)
;
test
(
'Adding multiple raw matches'
,
function
(
)
{
const
=
aSearchResult
(
)
;
const
=
[
aRawMatch
(
'/1'
,
new
TextSearchMatch
(
'preview 1'
,
new
OneLineRange
(
1
,
1
,
4
)
)
,
new
TextSearchMatch
(
'preview 1'
,
new
OneLineRange
(
1
,
4
,
11
)
)
)
,
aRawMatch
(
'/2'
,
new
TextSearchMatch
(
'preview 2'
,
)
)
]
;
addToSearchResult
(
,
)
;
.
strictEqual
(
3
,
.
count
(
)
)
;
const
=
.
matches
(
)
;
.
strictEqual
(
2
,
.
)
;
.
strictEqual
(
URI
.
file
(
` ${ getRootName ( ) } /1 `
)
.
toString
(
)
,
[
0
]
.
.
toString
(
)
)
;
let
=
[
0
]
.
matches
(
)
;
.
strictEqual
(
2
,
.
)
;
.
strictEqual
(
'preview 1'
,
[
0
]
.
text
(
)
)
;
.
ok
(
new
Range
(
2
,
2
,
2
,
5
)
.
equalsRange
(
[
0
]
.
range
(
)
)
)
;
.
strictEqual
(
'preview 1'
,
[
1
]
.
text
(
)
)
;
.
ok
(
new
Range
(
2
,
5
,
2
,
12
)
.
equalsRange
(
[
1
]
.
range
(
)
)
)
;
=
[
1
]
.
matches
(
)
;
.
strictEqual
(
1
,
.
)
;
.
strictEqual
(
'preview 2'
,
[
0
]
.
text
(
)
)
;
.
ok
(
new
Range
(
2
,
1
,
2
,
2
)
.
equalsRange
(
[
0
]
.
range
(
)
)
)
;
}
)
;
test
(
'Test that notebook matches get added correctly'
,
function
(
)
{
const
=
aSearchResult
(
)
;
const
=
{
:
.
}
as
;
const
=
{
:
.
}
as
;
.
stub
(
.
,
'addContext'
)
;
const
=
.
spy
(
.
,
'addFileMatch'
)
;
const
=
aRawFileMatchWithCells
(
'/1'
,
{
:
,
:
0
,
:
[
new
TextSearchMatch
(
'preview 1'
,
new
OneLineRange
(
1
,
1
,
4
)
)
,
]
,
:
[
new
TextSearchMatch
(
'preview 1'
,
new
OneLineRange
(
1
,
4
,
11
)
)
,
new
TextSearchMatch
(
'preview 2'
,
)
]
}
,
)
;
const
=
aRawFileMatchWithCells
(
'/2'
,
{
:
,
:
0
,
:
[
new
TextSearchMatch
(
'preview 1'
,
new
OneLineRange
(
1
,
1
,
4
)
)
,
]
,
:
[
new
TextSearchMatch
(
'preview 1'
,
new
OneLineRange
(
1
,
4
,
11
)
)
,
new
TextSearchMatch
(
'preview 2'
,
)
]
}
)
;
const
=
[
,
]
;
addToSearchResult
(
,
)
;
.
strictEqual
(
6
,
.
count
(
)
)
;
.
deepStrictEqual
(
.
[
0
]
.
,
(
.
getCall
(
0
)
.
[
0
]
[
0
]
as
)
.
[
0
]
.
)
;
.
deepStrictEqual
(
.
[
0
]
.
,
(
.
getCall
(
0
)
.
[
0
]
[
0
]
as
)
.
[
0
]
.
)
;
.
deepStrictEqual
(
.
[
0
]
.
,
(
.
getCall
(
0
)
.
[
0
]
[
1
]
as
)
.
[
0
]
.
)
;
.
deepStrictEqual
(
.
[
0
]
.
,
(
.
getCall
(
0
)
.
[
0
]
[
1
]
as
)
.
[
0
]
.
)
;
}
)
;
test
(
'Dispose disposes matches'
,
function
(
)
{
const
=
.
spy
(
)
;
const
=
.
spy
(
)
;
const
=
aSearchResult
(
)
;
addToSearchResult
(
,
[
aRawMatch
(
'/1'
,
new
TextSearchMatch
(
'preview 1'
,
)
)
,
aRawMatch
(
'/2'
,
new
TextSearchMatch
(
'preview 2'
,
)
)
]
)
;
.
add
(
.
matches
(
)
[
0
]
.
onDispose
(
)
)
;
.
add
(
.
matches
(
)
[
1
]
.
onDispose
(
)
)
;
.
dispose
(
)
;
.
ok
(
.
isEmpty
(
)
)
;
.
ok
(
.
)
;
.
ok
(
.
)
;
}
)
;
test
(
'remove triggers change event'
,
function
(
)
{
const
=
.
spy
(
)
;
const
=
aSearchResult
(
)
;
addToSearchResult
(
,
[
aRawMatch
(
'/1'
,
new
TextSearchMatch
(
'preview 1'
,
)
)
]
)
;
const
=
.
matches
(
)
[
0
]
;
.
add
(
.
onChange
(
)
)
;
.
remove
(
)
;
.
ok
(
.
)
;
.
deepStrictEqual
(
[
{
:
[
]
,
:
true
}
]
,
.
[
0
]
)
;
}
)
;
test
(
'remove array triggers change event'
,
function
(
)
{
const
=
.
spy
(
)
;
const
=
aSearchResult
(
)
;
addToSearchResult
(
,
[
aRawMatch
(
'/1'
,
new
TextSearchMatch
(
'preview 1'
,
)
)
,
aRawMatch
(
'/2'
,
new
TextSearchMatch
(
'preview 2'
,
)
)
]
)
;
const
=
.
matches
(
)
;
.
add
(
.
onChange
(
)
)
;
.
remove
(
)
;
.
ok
(
.
)
;
.
deepStrictEqual
(
[
{
:
,
:
true
}
]
,
.
[
0
]
)
;
}
)
;
test
(
'Removing all line matches and adding back will add file back to result'
,
function
(
)
{
const
=
aSearchResult
(
)
;
addToSearchResult
(
,
[
aRawMatch
(
'/1'
,
new
TextSearchMatch
(
'preview 1'
,
)
)
]
)
;
const
=
.
matches
(
)
[
0
]
;
const
=
.
matches
(
)
[
0
]
;
.
remove
(
)
;
.
ok
(
.
isEmpty
(
)
)
;
.
add
(
,
true
)
;
.
strictEqual
(
1
,
.
fileCount
(
)
)
;
.
strictEqual
(
,
.
matches
(
)
[
0
]
)
;
}
)
;
test
(
'replace should remove the file match'
,
function
(
)
{
const
=
Promise
.
resolve
(
null
)
;
.
stub
(
,
'replace'
,
)
;
const
=
aSearchResult
(
)
;
addToSearchResult
(
,
[
aRawMatch
(
'/1'
,
new
TextSearchMatch
(
'preview 1'
,
)
)
]
)
;
.
replace
(
.
matches
(
)
[
0
]
)
;
return
.
then
(
(
)
=>
.
ok
(
.
isEmpty
(
)
)
)
;
}
)
;
test
(
'replace should trigger the change event'
,
function
(
)
{
const
=
.
spy
(
)
;
const
=
Promise
.
resolve
(
null
)
;
.
stub
(
,
'replace'
,
)
;
const
=
aSearchResult
(
)
;
addToSearchResult
(
,
[
aRawMatch
(
'/1'
,
new
TextSearchMatch
(
'preview 1'
,
)
)
]
)
;
.
add
(
.
onChange
(
)
)
;
const
=
.
matches
(
)
[
0
]
;
.
replace
(
)
;
return
.
then
(
(
)
=>
{
.
ok
(
.
)
;
.
deepStrictEqual
(
[
{
:
[
]
,
:
true
}
]
,
.
[
0
]
)
;
}
)
;
}
)
;
test
(
'replaceAll should remove all file matches'
,
function
(
)
{
const
=
Promise
.
resolve
(
null
)
;
.
stubPromise
(
,
'replace'
,
)
;
const
=
aSearchResult
(
)
;
addToSearchResult
(
,
[
aRawMatch
(
'/1'
,
new
TextSearchMatch
(
'preview 1'
,
)
)
,
aRawMatch
(
'/2'
,
new
TextSearchMatch
(
'preview 2'
,
)
)
]
)
;
.
replaceAll
(
null
!
)
;
return
.
then
(
(
)
=>
.
ok
(
.
isEmpty
(
)
)
)
;
}
)
;
test
(
'batchRemove should trigger the onChange event correctly'
,
function
(
)
{
const
=
.
spy
(
)
;
const
=
getPopulatedSearchResult
(
)
;
const
=
.
folderMatches
(
)
[
0
]
;
const
=
.
folderMatches
(
)
[
1
]
.
allDownstreamFileMatches
(
)
[
0
]
;
const
=
.
folderMatches
(
)
[
1
]
.
allDownstreamFileMatches
(
)
[
1
]
.
matches
(
)
[
0
]
;
const
=
[
,
,
]
;
const
=
.
allDownstreamFileMatches
(
)
.
concat
(
[
,
.
parent
(
)
]
)
;
.
add
(
.
onChange
(
)
)
;
.
batchRemove
(
)
;
.
ok
(
.
)
;
.
deepStrictEqual
(
[
{
:
,
:
true
,
:
false
}
]
,
.
[
0
]
)
;
}
)
;
test
(
'batchRemove should remove FolderMatchNoRoot (Other files) correctly'
,
function
(
)
{
const
=
.
spy
(
)
;
const
=
aSearchResult
(
)
;
.
=
{
:
.
,
:
{
:
'foo'
}
,
:
[
{
:
createFileUriFromPathFromRoot
(
'/workspace'
)
}
]
}
;
addToSearchResult
(
,
[
aRawMatch
(
'/workspace/file.txt'
,
new
TextSearchMatch
(
'preview 1'
,
)
)
,
]
)
;
addToSearchResult
(
,
[
aRawMatch
(
'/other/outside.txt'
,
new
TextSearchMatch
(
'preview 2'
,
)
)
,
]
)
;
const
=
.
folderMatches
(
)
;
.
strictEqual
(
.
,
2
)
;
const
=
.
find
(
=>
isSearchTreeFolderMatchNoRoot
(
)
)
;
.
ok
(
,
'Should have an Other files folder match'
)
;
.
strictEqual
(
.
allDownstreamFileMatches
(
)
.
,
1
)
;
.
add
(
.
onChange
(
)
)
;
.
batchRemove
(
[
]
)
;
.
ok
(
.
)
;
.
strictEqual
(
.
allDownstreamFileMatches
(
)
.
,
0
)
;
}
)
;
test
(
'folder matches are not retained across queries'
,
function
(
)
{
const
=
aSearchResult
(
)
;
const
=
.
folderMatches
(
)
.
map
(
=>
.
spy
(
,
'dispose'
)
)
;
for
(
const
of
[
'/second'
,
'/third'
]
)
{
.
=
{
:
.
,
:
{
:
''
}
,
:
[
{
:
createFileUriFromPathFromRoot
(
)
}
]
}
;
.
add
(
[
]
,
'test'
,
false
)
;
}
.
dispose
(
)
;
.
deepStrictEqual
(
.
map
(
=>
.
)
,
[
1
,
1
]
)
;
}
)
;
test
(
'batchReplace should trigger the onChange event correctly'
,
async
function
(
)
{
const
=
.
spy
(
)
;
.
stub
(
,
'replace'
,
(
:
any
)
=>
{
if
(
Array
.
isArray
(
)
)
{
replaceSpy
(
[
0
]
)
;
}
else
{
replaceSpy
(
)
;
}
return
Promise
.
resolve
(
)
;
}
)
;
const
=
.
spy
(
)
;
const
=
getPopulatedSearchResult
(
)
;
const
=
.
folderMatches
(
)
[
0
]
;
const
=
.
folderMatches
(
)
[
1
]
.
allDownstreamFileMatches
(
)
[
0
]
;
const
=
.
folderMatches
(
)
[
1
]
.
allDownstreamFileMatches
(
)
[
1
]
.
matches
(
)
[
0
]
;
const
=
.
allDownstreamFileMatches
(
)
[
0
]
;
const
=
[
,
,
]
;
.
add
(
.
onChange
(
)
)
;
await
.
batchReplace
(
)
;
.
ok
(
.
)
;
.
.
calledThrice
(
)
;
.
.
calledWith
(
.
,
)
;
.
.
calledWith
(
.
,
)
;
.
.
calledWith
(
.
,
)
;
}
)
;
test
(
'Creating a model with nested folders should create the correct structure'
,
function
(
)
{
const
=
getPopulatedSearchResultForTreeTesting
(
)
;
const
=
.
folderMatches
(
)
[
0
]
;
const
=
.
folderMatches
(
)
[
1
]
;
const
=
.
folderMatches
(
)
[
2
]
;
const
=
.
folderMatches
(
)
[
3
]
;
const
=
.
allDownstreamFileMatches
(
)
;
.
deepStrictEqual
(
,
[
...
.
fileMatchesIterator
(
)
,
...
getFolderMatchAtIndex
(
,
0
)
.
fileMatchesIterator
(
)
]
)
;
.
deepStrictEqual
(
getFolderMatchAtIndex
(
,
0
)
.
allDownstreamFileMatches
(
)
,
Array
.
from
(
getFolderMatchAtIndex
(
,
0
)
.
fileMatchesIterator
(
)
)
)
;
.
deepStrictEqual
(
getFileMatchAtIndex
(
getFolderMatchAtIndex
(
,
0
)
,
0
)
.
parent
(
)
,
getFolderMatchAtIndex
(
,
0
)
)
;
.
deepStrictEqual
(
getFolderMatchAtIndex
(
,
0
)
.
parent
(
)
,
)
;
.
deepStrictEqual
(
(
getFolderMatchAtIndex
(
,
0
)
as
)
.
,
)
;
.
forEach
(
(
)
=>
{
.
deepStrictEqual
(
.
,
)
;
}
)
;
const
=
.
allDownstreamFileMatches
(
)
;
.
deepStrictEqual
(
.
allDownstreamFileMatches
(
)
,
[
...
.
fileMatchesIterator
(
)
,
...
getFolderMatchAtIndex
(
,
0
)
.
fileMatchesIterator
(
)
]
)
;
.
deepStrictEqual
(
getFileMatchAtIndex
(
getFolderMatchAtIndex
(
,
0
)
,
0
)
.
parent
(
)
,
getFolderMatchAtIndex
(
,
0
)
)
;
.
forEach
(
(
)
=>
{
.
deepStrictEqual
(
.
,
)
;
}
)
;
const
=
.
allDownstreamFileMatches
(
)
;
.
deepStrictEqual
(
,
Array
.
from
(
.
fileMatchesIterator
(
)
)
)
;
.
deepStrictEqual
(
getFileMatchAtIndex
(
,
0
)
.
parent
(
)
,
)
;
.
deepStrictEqual
(
getFileMatchAtIndex
(
,
0
)
.
,
)
;
const
=
.
allDownstreamFileMatches
(
)
;
const
=
getFolderMatchAtIndex
(
getFolderMatchAtIndex
(
,
0
)
,
0
)
;
.
deepStrictEqual
(
,
[
...
.
fileMatchesIterator
(
)
,
...
getFolderMatchAtIndex
(
,
0
)
.
fileMatchesIterator
(
)
,
...
getFolderMatchAtIndex
(
,
1
)
.
fileMatchesIterator
(
)
]
.
flat
(
)
)
;
.
deepStrictEqual
(
.
allDownstreamFileMatches
(
)
,
getFolderMatchAtIndex
(
,
0
)
.
allDownstreamFileMatches
(
)
)
;
.
deepStrictEqual
(
getFileMatchAtIndex
(
getFolderMatchAtIndex
(
,
1
)
,
0
)
.
parent
(
)
,
getFolderMatchAtIndex
(
,
1
)
)
;
.
deepStrictEqual
(
getFolderMatchAtIndex
(
,
1
)
.
parent
(
)
,
)
;
.
deepStrictEqual
(
.
parent
(
)
,
getFolderMatchAtIndex
(
,
0
)
)
;
.
forEach
(
(
)
=>
{
.
deepStrictEqual
(
.
,
)
;
}
)
;
}
)
;
test
(
'Removing an intermediate folder should call OnChange() on all downstream file matches'
,
function
(
)
{
const
=
.
spy
(
)
;
const
=
getPopulatedSearchResultForTreeTesting
(
)
;
const
=
getFolderMatchAtIndex
(
getFolderMatchAtIndex
(
getFolderMatchAtIndex
(
.
folderMatches
(
)
[
3
]
,
0
)
,
0
)
,
0
)
;
const
=
.
allDownstreamFileMatches
(
)
;
.
add
(
.
onChange
(
)
)
;
.
remove
(
)
;
.
ok
(
.
)
;
.
deepStrictEqual
(
[
{
:
,
:
true
,
:
false
,
:
false
}
]
,
.
[
0
]
)
;
}
)
;
test
(
'Replacing an intermediate folder should remove all downstream folders and file matches'
,
async
function
(
)
{
const
=
.
spy
(
)
;
const
=
getPopulatedSearchResultForTreeTesting
(
)
;
const
=
getFolderMatchAtIndex
(
.
folderMatches
(
)
[
3
]
,
0
)
;
const
=
.
allDownstreamFileMatches
(
)
;
.
add
(
.
onChange
(
)
)
;
await
.
batchReplace
(
[
]
)
;
.
deepStrictEqual
(
[
{
:
,
:
true
,
:
false
}
]
,
.
[
0
]
)
;
}
)
;
function
aFileMatch
(
:
string
,
:
|
undefined
,
...
:
[
]
)
:
{
if
(
!
)
{
=
aSearchResult
(
)
;
}
const
:
=
{
:
URI
.
file
(
'/'
+
)
,
:
}
;
const
=
?.
folderMatches
(
)
[
0
]
;
const
=
.
createInstance
(
,
{
:
''
}
,
undefined
,
undefined
,
,
,
null
,
''
)
;
.
createMatches
(
)
;
.
add
(
)
;
return
;
}
function
aSearchResult
(
)
:
{
const
=
.
createInstance
(
)
;
.
add
(
)
;
.
.
=
{
:
.
,
:
[
{
:
createFileUriFromPathFromRoot
(
)
}
]
,
:
{
:
''
}
}
;
return
.
;
}
function
aRawMatch
(
:
string
,
...
:
[
]
)
:
{
return
{
:
createFileUriFromPathFromRoot
(
)
,
}
;
}
function
aRawFileMatchWithCells
(
:
string
,
...
:
[
]
)
:
{
return
{
:
createFileUriFromPathFromRoot
(
)
,
:
}
;
}
function
stubModelService
(
:
)
:
{
.
stub
(
,
new
TestThemeService
(
)
)
;
const
=
new
TestConfigurationService
(
)
;
.
setUserConfiguration
(
'search'
,
{
:
true
}
)
;
.
stub
(
,
)
;
const
=
.
createInstance
(
)
;
.
add
(
)
;
return
;
}
function
stubNotebookEditorService
(
:
)
:
{
.
stub
(
,
new
TestEditorGroupsService
(
)
)
;
.
stub
(
,
new
MockContextKeyService
(
)
)
;
.
stub
(
,
.
add
(
new
TestEditorService
(
)
)
)
;
const
=
.
createInstance
(
)
;
.
add
(
)
;
return
;
}
function
getPopulatedSearchResult
(
)
{
const
=
aSearchResult
(
)
;
.
=
{
:
.
,
:
{
:
'foo'
}
,
:
[
{
:
createFileUriFromPathFromRoot
(
'/voo'
)
}
,
{
:
createFileUriFromPathFromRoot
(
'/with'
)
}
,
]
}
;
addToSearchResult
(
,
[
aRawMatch
(
'/voo/foo.a'
,
new
TextSearchMatch
(
'preview 1'
,
)
,
new
TextSearchMatch
(
'preview 2'
,
)
)
,
aRawMatch
(
'/with/path/bar.b'
,
new
TextSearchMatch
(
'preview 3'
,
)
)
,
aRawMatch
(
'/with/path.c'
,
new
TextSearchMatch
(
'preview 4'
,
)
,
new
TextSearchMatch
(
'preview 5'
,
)
)
,
]
)
;
return
;
}
function
getPopulatedSearchResultForTreeTesting
(
)
{
const
=
aSearchResult
(
)
;
.
=
{
:
.
,
:
{
:
'foo'
}
,
:
[
{
:
createFileUriFromPathFromRoot
(
'/voo'
)
}
,
{
:
createFileUriFromPathFromRoot
(
'/with'
)
}
,
{
:
createFileUriFromPathFromRoot
(
'/with/test'
)
}
,
{
:
createFileUriFromPathFromRoot
(
'/eep'
)
}
,
]
}
;
addToSearchResult
(
,
[
aRawMatch
(
'/voo/foo.a'
,
new
TextSearchMatch
(
'preview 1'
,
)
,
new
TextSearchMatch
(
'preview 2'
,
)
)
,
aRawMatch
(
'/voo/beep/foo.c'
,
new
TextSearchMatch
(
'preview 1'
,
)
,
new
TextSearchMatch
(
'preview 2'
,
)
)
,
aRawMatch
(
'/voo/beep/boop.c'
,
new
TextSearchMatch
(
'preview 3'
,
)
)
,
aRawMatch
(
'/with/path.c'
,
new
TextSearchMatch
(
'preview 4'
,
)
,
new
TextSearchMatch
(
'preview 5'
,
)
)
,
aRawMatch
(
'/with/path/bar.b'
,
new
TextSearchMatch
(
'preview 3'
,
)
)
,
aRawMatch
(
'/with/test/woo.c'
,
new
TextSearchMatch
(
'preview 3'
,
)
)
,
aRawMatch
(
'/eep/bar/goo/foo/here.txt'
,
new
TextSearchMatch
(
'preview 6'
,
)
,
new
TextSearchMatch
(
'preview 7'
,
)
)
,
aRawMatch
(
'/eep/bar/goo/ooo/there.txt'
,
new
TextSearchMatch
(
'preview 6'
,
)
,
new
TextSearchMatch
(
'preview 7'
,
)
)
,
aRawMatch
(
'/eep/eyy.y'
,
new
TextSearchMatch
(
'preview 6'
,
)
,
new
TextSearchMatch
(
'preview 7'
,
)
)
]
)
;
return
;
}
function
getFolderMatchAtIndex
(
:
,
:
number
)
{
return
Array
.
from
(
.
folderMatchesIterator
(
)
)
[
]
;
}
function
getFileMatchAtIndex
(
:
,
:
number
)
{
return
Array
.
from
(
.
fileMatchesIterator
(
)
)
[
]
;
}
}
)
;