ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / copilot / src / extension / inlineEdits / test / vscode-node / inlineEditTriggerer.spec.ts 1323 строк · изменён 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
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
import { afterEach, assert, beforeEach, suite, test } from 'vitest' ;
import { TextDocumentChangeReason, TextEditor, type TextDocument } from 'vscode' ;
import { ConfigKey, IConfigurationService } from '../../../../platform/configuration/common/configurationService' ;
import { InMemoryConfigurationService } from '../../../../platform/configuration/test/common/inMemoryConfigurationService' ;
import { DocumentId } from '../../../../platform/inlineEdits/common/dataTypes/documentId' ;
import { DocumentSwitchTriggerStrategy } from '../../../../platform/inlineEdits/common/dataTypes/triggerOptions'
ILogService
IExperimentationService
TestWorkspaceService
createTextDocumentData
ExtHostTextEditor
DisposableStore
IReader
Selection TextEditorSelectionChangeKind Uri
createExtensionUnitTestingServices
NesChangeHint NesTriggerReason
NesOutcome NextEditProvider
InlineEditTriggerer
IVSCodeObservableDocument
disposables DisposableStore
vscWorkspace MockVSCodeWorkspace
workspaceService TestWorkspaceService
firedEvents NesChangeHint
nextEditProvider MockNextEditProvider
configurationService InMemoryConfigurationService
triggerer InlineEditTriggerer
lastRejectionTime Date
lastTriggerTime Date
lastOutcome NesOutcome
documents
doc TextDocument obsDoc IVSCodeObservableDocument
documents doc obsDoc
doc TextDocument _reader IReader IVSCodeObservableDocument
documents doc
disposables
firedEvents
vscWorkspace
nextEditProvider
workspaceService disposables
services disposables
accessor disposables services
configurationService accessor IConfigurationService InMemoryConfigurationService
triggerer disposables
vscWorkspace
nextEditProvider NextEditProvider
accessor ILogService
configurationService
accessor IExperimentationService
workspaceService
disposables triggerer e firedEvents e
disposables
document TextDocument reason TextDocumentChangeReason
workspaceService didChangeTextDocumentEmitter
document
contentChanges
reason
detailedReason
textEditor TextEditor selection Selection kind TextEditorSelectionChangeKind Keyboard
workspaceService didChangeTextEditorSelectionEmitter
kind
selections selection
textEditor
textEditor TextEditor selections Selection
workspaceService didChangeTextEditorSelectionEmitter
kind TextEditorSelectionChangeKind Keyboard
selections
textEditor
uri Uri IVSCodeObservableDocument
id DocumentId uri
_ range range
selection Selection
uri Uri Uri
content
document TextDocument textEditor TextEditor selection Selection
doc uri content
textEditor doc document selection
vscWorkspace doc document doc document uri
document doc document
textEditor textEditor value
selection
document TextDocument textEditor TextEditor selection Selection
uri Uri
doc uri
selection
textEditor doc document selection
document doc document textEditor textEditor value selection
NesTriggerReason
firedEvents data reason
textEditor selection
textEditor selection
assert firedEvents length
document textEditor selection
document
textEditor selection
assert firedEvents length
document textEditor
nextEditProvider lastRejectionTime Date
document
textEditor
assert firedEvents length
assert NesTriggerReason SelectionChange
document textEditor
nextEditProvider lastRejectionTime Date
document
textEditor
assert firedEvents length
document textEditor
nextEditProvider lastRejectionTime Date
document
textEditor
assert firedEvents length
document textEditor
nextEditProvider lastRejectionTime Date
document
textEditor
assert firedEvents length
document textEditor
nextEditProvider lastRejectionTime Date
document
nextEditProvider lastRejectionTime Date
textEditor
assert firedEvents length
textEditor
assert firedEvents length
document textEditor selection
nextEditProvider lastRejectionTime Date
document
textEditor selection
assert firedEvents length
document textEditor
vscWorkspace documents document
nextEditProvider lastRejectionTime Date
document
textEditor
assert firedEvents length
document textEditor
nextEditProvider lastRejectionTime Date
document TextDocumentChangeReason Undo
textEditor
assert firedEvents length
document textEditor
nextEditProvider lastRejectionTime Date
document TextDocumentChangeReason Redo
textEditor
assert firedEvents length
document
nextEditProvider lastRejectionTime Date
document
assert
document textEditor
nextEditProvider lastRejectionTime Date
document
textEditor
assert firedEvents length
document textEditor
nextEditProvider lastRejectionTime Date
nextEditProvider lastTriggerTime Date
document
textEditor
assert firedEvents length
document textEditor
nextEditProvider lastRejectionTime Date
nextEditProvider lastTriggerTime Date
document
textEditor
assert firedEvents length
document textEditor
nextEditProvider lastRejectionTime Date
document
textEditor
initialCount firedEvents length
assert initialCount
textEditor
assert firedEvents length initialCount
document textEditor
nextEditProvider lastRejectionTime Date
document
textEditor
initialCount firedEvents length
assert initialCount
textEditor
assert firedEvents length initialCount
assert
doc1 Uri
doc2 Uri
nextEditProvider lastRejectionTime Date
nextEditProvider lastOutcome NesOutcome Accepted
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
doc1 document
doc1 textEditor
initialCount firedEvents length
doc2 textEditor
assert firedEvents length initialCount
assert NesTriggerReason ActiveDocumentSwitch
document textEditor
nextEditProvider lastRejectionTime Date
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
document
textEditor
textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
doc1 Uri
doc2 Uri
nextEditProvider lastRejectionTime Date
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
doc1 document
doc1 textEditor
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
doc1 Uri
doc2 Uri
nextEditProvider lastRejectionTime Date
nextEditProvider lastTriggerTime
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
doc1 document
doc1 textEditor
initialCount firedEvents length
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
assert firedEvents length initialCount
doc1 Uri
doc2 Uri
nextEditProvider lastRejectionTime Date
triggerAfterSeconds
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds triggerAfterSeconds
doc1 document
doc1 textEditor
initialCount firedEvents length
nextEditProvider lastTriggerTime Date triggerAfterSeconds
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
assert firedEvents length initialCount
doc1 Uri
doc2 Uri
nextEditProvider lastRejectionTime Date
nextEditProvider lastOutcome NesOutcome Accepted
triggerAfterSeconds
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds triggerAfterSeconds
doc1 document
doc1 textEditor
initialCount firedEvents length
nextEditProvider lastTriggerTime Date triggerAfterSeconds
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
assert firedEvents length initialCount
document textEditor
nextEditProvider lastRejectionTime Date
configurationService ConfigKey TeamInternal InlineEditsDebounceOnSelectionChange
document
textEditor
assert firedEvents length
textEditor
assert firedEvents length
document textEditor
nextEditProvider lastRejectionTime Date
debounceMs
configurationService ConfigKey TeamInternal InlineEditsDebounceOnSelectionChange debounceMs
document
textEditor
textEditor
assert firedEvents length
textEditor
assert firedEvents length
resolve resolve debounceMs
assert firedEvents length
document textEditor
nextEditProvider lastRejectionTime Date
configurationService ConfigKey TeamInternal InlineEditsDebounceOnSelectionChange
document
textEditor
textEditor
textEditor
textEditor
assert firedEvents length
document textEditor
nextEditProvider lastRejectionTime Date
document
textEditor
assert firedEvents length
event firedEvents
assert NesChangeHint event
assert event data uuid
assert event data uuid
assert event data reason NesTriggerReason SelectionChange
document textEditor
nextEditProvider lastRejectionTime Date
document
textEditor
textEditor
assert firedEvents length
uuids firedEvents e e data uuid
uniqueUuids uuids
assert uniqueUuids size uuids length
uri Uri
doc uri
selection
textEditor doc document selection
obsDoc IVSCodeObservableDocument
id DocumentId uri
vscWorkspace doc document obsDoc
nextEditProvider lastRejectionTime Date
doc document
textEditor value
assert firedEvents length
cellId
content
document TextDocument textEditor TextEditor
uri Uri
doc uri content
selection
textEditor doc document selection
vscWorkspace doc document doc document uri
document doc document textEditor textEditor value
cell1
cell2
nextEditProvider lastRejectionTime Date
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
cell1 document
cell1 textEditor
countAfterFirst firedEvents length
assert countAfterFirst
cell2 document
cell2 textEditor
countAfterSecond firedEvents length
assert countAfterSecond countAfterFirst
cell1 document
cell2 document
cell2 textEditor
countBeforeBypass firedEvents length
cell2Alt
cell2Alt textEditor
assert firedEvents length countBeforeBypass
cell
nextEditProvider lastRejectionTime Date
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
cell document
cell textEditor
countAfterFirst firedEvents length
assert countAfterFirst
cell textEditor
assert firedEvents length countAfterFirst
lines length _ i
document textEditor lines
nextEditProvider lastRejectionTime Date
document
i i i
textEditor i i
assert firedEvents length
textEditor
assert firedEvents length
document textEditor
nextEditProvider lastRejectionTime Date
debounceMs
configurationService ConfigKey TeamInternal InlineEditsDebounceOnSelectionChange debounceMs
document
textEditor
textEditor
textEditor
assert firedEvents length
resolve resolve debounceMs
assert firedEvents length
document
textEditor
assert firedEvents length
textEditor
assert firedEvents length
textEditor
assert firedEvents length
lines length _ i
document textEditor lines
nextEditProvider lastRejectionTime Date
debounceMs
configurationService ConfigKey TeamInternal InlineEditsDebounceOnSelectionChange debounceMs
document
textEditor
textEditor
assert firedEvents length
textEditor
assert firedEvents length
textEditor
assert firedEvents length
resolve resolve debounceMs
assert firedEvents length
doc1 Uri
uri2 Uri
doc2Data uri2
doc2Editor doc2Data document
nextEditProvider lastRejectionTime Date
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
doc1 document
doc1 textEditor
initialCount firedEvents length
doc2Editor value
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
assert firedEvents length initialCount
doc1 Uri
uri2 Uri
doc2Data uri2
doc2Editor doc2Data document
obsDoc2 IVSCodeObservableDocument
id DocumentId uri2
vscWorkspace doc2Data document obsDoc2
nextEditProvider lastRejectionTime Date
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
doc1 document
doc1 textEditor
initialCount firedEvents length
doc2Editor value
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
assert firedEvents length initialCount
doc1 Uri
doc2 Uri
nextEditProvider lastRejectionTime Date
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
doc1 textEditor
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
doc1 Uri
doc2 Uri
nextEditProvider lastRejectionTime Date
nextEditProvider lastOutcome NesOutcome Accepted
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
doc1 document
doc1 textEditor
doc2 textEditor
assert NesTriggerReason ActiveDocumentSwitch
countAfterSwitch firedEvents length
doc2 textEditor
assert firedEvents length countAfterSwitch
assert NesTriggerReason SelectionChange
doc1 Uri
doc2 Uri
nextEditProvider lastRejectionTime Date
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
configurationService ConfigKey TeamInternal InlineEditsTriggerOnEditorChangeStrategy DocumentSwitchTriggerStrategy AfterAcceptance
doc1 document
doc1 textEditor
doc1 doc2 eventsBeforeSwitch firedEvents length
doc2 eventsBeforeSwitch
nextEditProvider lastOutcome NesOutcome Accepted
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
assert firedEvents length eventsBeforeSwitch
doc2 eventsBeforeSwitch
nextEditProvider lastOutcome NesOutcome Rejected
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
assert firedEvents length eventsBeforeSwitch
doc2 eventsBeforeSwitch
nextEditProvider lastOutcome NesOutcome Ignored
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
assert firedEvents length eventsBeforeSwitch
doc2 eventsBeforeSwitch
nextEditProvider lastOutcome
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
assert firedEvents length eventsBeforeSwitch
doc1 Uri
doc2 Uri
nextEditProvider lastRejectionTime Date
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
configurationService ConfigKey TeamInternal InlineEditsTriggerOnEditorChangeStrategy DocumentSwitchTriggerStrategy Always
nextEditProvider lastOutcome NesOutcome Rejected
doc1 document
doc1 textEditor
eventsBeforeSwitch firedEvents length
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
assert firedEvents length eventsBeforeSwitch
doc1 Uri
doc2 Uri
nextEditProvider lastRejectionTime Date
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
configurationService ConfigKey TeamInternal InlineEditsTriggerOnEditorChangeStrategy DocumentSwitchTriggerStrategy Always
nextEditProvider lastOutcome NesOutcome Ignored
doc1 document
doc1 textEditor
eventsBeforeSwitch firedEvents length
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
assert firedEvents length eventsBeforeSwitch
doc2 eventsBeforeSwitch
nextEditProvider lastOutcome NesOutcome Accepted
nextEditProvider lastOutcome
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
assert firedEvents length eventsBeforeSwitch
doc2
nextEditProvider lastOutcome
nextEditProvider lastOutcome NesOutcome Accepted
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
doc2 eventsBeforeSwitch
nextEditProvider lastOutcome
nextEditProvider lastOutcome NesOutcome Rejected
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
assert firedEvents length eventsBeforeSwitch
uri Uri
doc uri
trackedDoc Uri
nextEditProvider lastRejectionTime Date
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
doc document
trackedDoc textEditor
doc2 Uri
doc2 textEditor
assert
doc1 Uri
doc2 Uri
nextEditProvider lastRejectionTime Date
nextEditProvider lastOutcome NesOutcome Accepted
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
doc1 document TextDocumentChangeReason Undo
doc1 textEditor
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
doc1 Uri
doc2 Uri
document outputDocument
nextEditProvider lastRejectionTime Date
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
outputDocument
doc1 textEditor
doc2 textEditor
switchEvents firedEvents e e data reason NesTriggerReason ActiveDocumentSwitch
assert switchEvents length
doc1 Uri
doc2 Uri
nextEditProvider lastRejectionTime Date
configurationService ConfigKey Advanced InlineEditsTriggerOnEditorChangeAfterSeconds
doc1 document
doc1 textEditor
assert firedEvents length
doc2 textEditor
assert firedEvents length
doc1 Uri
doc2 Uri
nextEditProvider lastRejectionTime Date
doc1 document
doc1 textEditor
initialCount firedEvents length
assert initialCount
doc1 textEditor
assert firedEvents length initialCount
doc2 document
doc2 textEditor
countAfterDoc2 firedEvents length
doc1 textEditor
assert firedEvents length countAfterDoc2
textEditor selection
nextEditProvider lastRejectionTime Date
textEditor selection
assert firedEvents length
uri Uri
doc uri
textEditor doc document
nextEditProvider lastRejectionTime Date
doc document
textEditor value
assert firedEvents length
doc1 Uri
doc2 Uri
nextEditProvider lastRejectionTime Date
doc1 document
doc1 textEditor
assert firedEvents length
doc2 document
doc2 textEditor
assert firedEvents length
doc1 textEditor
assert firedEvents length
doc2 textEditor
assert firedEvents length
document textEditor
nextEditProvider lastRejectionTime Date
document
textEditor
count1 firedEvents length
assert count1
textEditor
assert firedEvents length count1
document
textEditor
assert firedEvents length count1
;
import
{
}
from
'../../../../platform/log/common/logService'
;
import
{
}
from
'../../../../platform/telemetry/common/nullExperimentationService'
;
import
{
}
from
'../../../../platform/test/node/testWorkspaceService'
;
import
{
}
from
'../../../../util/common/test/shims/textDocument'
;
import
{
}
from
'../../../../util/common/test/shims/textEditor'
;
import
{
}
from
'../../../../util/vs/base/common/lifecycle'
;
import
{
}
from
'../../../../util/vs/base/common/observableInternal'
;
import
{
,
,
}
from
'../../../../vscodeTypes'
;
import
{
}
from
'../../../test/node/services'
;
import
{
,
}
from
'../../common/nesTriggerHint'
;
import
{
,
}
from
'../../node/nextEditProvider'
;
import
{
,
TRIGGER_INLINE_EDIT_AFTER_CHANGE_LIMIT
,
TRIGGER_INLINE_EDIT_ON_SAME_LINE_COOLDOWN
,
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
}
from
'../../vscode-node/inlineEditTriggerer'
;
import
{
}
from
'../../vscode-node/parts/vscodeWorkspace'
;
suite
(
'InlineEditTriggerer'
,
(
)
=>
{
let
:
;
let
:
;
let
:
;
let
:
[
]
;
let
:
;
let
:
;
let
:
;
class
MockNextEditProvider
{
public
:
number
=
.
now
(
)
;
public
:
number
=
.
now
(
)
;
public
:
|
undefined
=
undefined
;
}
class
MockVSCodeWorkspace
{
public
readonly
=
new
WeakMap< TextDocument, IVSCodeObservableDocument>
(
)
;
public
addDoc
(
:
,
:
)
:
void
{
this
.
.
set
(
,
)
;
}
public
getDocumentByTextDocument
(
:
,
?
:
)
:
|
undefined
{
return
this
.
.
get
(
)
;
}
}
beforeEach
(
(
)
=>
{
=
new
DisposableStore
(
)
;
=
[
]
;
=
new
MockVSCodeWorkspace
(
)
;
=
new
MockNextEditProvider
(
)
;
=
.
add
(
new
TestWorkspaceService
(
)
)
;
const
=
.
add
(
createExtensionUnitTestingServices
(
)
)
;
const
=
.
add
(
.
createTestingAccessor
(
)
)
;
=
.
get
(
)
as
;
=
.
add
(
new
InlineEditTriggerer
(
as
any
,
as
any
as
,
.
get
(
)
,
,
.
get
(
)
,
)
)
;
.
add
(
.
onChange
(
=>
.
push
(
)
)
)
;
}
)
;
afterEach
(
(
)
=>
{
.
dispose
(
)
;
}
)
;
function
triggerTextChange
(
:
,
?
:
)
:
void
{
.
.
fire
(
{
,
:
[
]
,
,
:
undefined
,
}
)
;
}
function
triggerTextSelectionChange
(
:
,
:
,
=
.
)
:
void
{
.
.
fire
(
{
,
:
[
]
,
,
}
)
;
}
function
triggerMultipleSelectionChange
(
:
,
:
[
]
)
:
void
{
.
.
fire
(
{
:
.
,
,
,
}
)
;
}
function
createObservableTextDoc
(
:
)
:
{
return
{
:
.
create
(
.
toString
(
)
)
,
toRange
:
(
:
any
,
:
any
)
=>
}
as
any
;
}
function
createTextDocument
(
:
=
new
Selection
(
0
,
0
,
0
,
0
)
,
:
=
.
file
(
'sample.py'
)
,
=
'print("Hello World")'
)
:
{
:
;
:
;
:
}
{
const
=
createTextDocumentData
(
,
,
'python'
)
;
const
=
new
ExtHostTextEditor
(
.
,
[
]
,
{
}
,
[
]
,
undefined
)
;
.
addDoc
(
.
,
createObservableTextDoc
(
.
.
)
)
;
return
{
:
.
,
:
.
,
}
;
}
function
createOutputDocument
(
)
:
{
:
;
:
;
:
}
{
const
=
.
parse
(
'output:extension-output-GitHub.copilot-chat-#1-GitHub Copilot Chat'
)
;
const
=
createTextDocumentData
(
,
'output logs'
,
'log'
)
;
const
=
new
Selection
(
0
,
0
,
0
,
0
)
;
const
=
new
ExtHostTextEditor
(
.
,
[
]
,
{
}
,
[
]
,
undefined
)
;
return
{
:
.
,
:
.
,
}
;
}
function
getLastFiredReason
(
)
:
|
undefined
{
return
.
at
(
-
1
)
?.
.
;
}
suite
(
'Basic behaviors'
,
(
)
=>
{
test
(
'No signal if there were no text changes'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
triggerTextSelectionChange
(
,
)
;
.
strictEqual
(
.
,
0
,
'Signal should not have been fired'
)
;
}
)
;
test
(
'No signal if selection is not empty'
,
(
)
=>
{
const
{
,
,
}
=
createTextDocument
(
new
Selection
(
0
,
0
,
0
,
10
)
)
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
)
;
.
strictEqual
(
.
,
0
,
'Signal should not have been fired'
)
;
}
)
;
test
(
'Signal fires when text changes and cursor moves with empty selection'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
isAtLeast
(
.
,
1
,
'Signal should have been fired'
)
;
.
strictEqual
(
getLastFiredReason
(
)
,
.
)
;
}
)
;
test
(
'No signal with multiple selections'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
)
;
triggerMultipleSelectionChange
(
,
[
new
Selection
(
0
,
0
,
0
,
0
)
,
new
Selection
(
1
,
0
,
1
,
0
)
]
)
;
.
strictEqual
(
.
,
0
,
'Signal should not have been fired for multiple selections'
)
;
}
)
;
}
)
;
suite
(
'Rejection cooldown'
,
(
)
=>
{
test
(
'No signal when last rejection was within cooldown period'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
.
=
.
now
(
)
-
(
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1000
)
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
strictEqual
(
.
,
0
,
'Signal should not fire during rejection cooldown'
)
;
}
)
;
test
(
'Signal fires when last rejection was over cooldown ago'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
.
=
.
now
(
)
-
(
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
+
1
)
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
isAtLeast
(
.
,
1
,
'Signal should have been fired'
)
;
}
)
;
test
(
'Rejection clears tracking for the document'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
)
;
.
=
.
now
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
strictEqual
(
.
,
0
,
'Signal should not fire'
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
10
,
0
,
10
)
)
;
.
strictEqual
(
.
,
0
,
'Signal should still not fire as doc was cleared'
)
;
}
)
;
}
)
;
suite
(
'Document filtering'
,
(
)
=>
{
test
(
'Ignores output pane documents for text changes'
,
(
)
=>
{
const
{
,
,
}
=
createOutputDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
)
;
.
strictEqual
(
.
,
0
,
'Signal should not fire for output documents'
)
;
}
)
;
test
(
'Ignores copilot-ignored documents (not in workspace)'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
.
.
delete
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
strictEqual
(
.
,
0
,
'Signal should not fire for ignored documents'
)
;
}
)
;
}
)
;
suite
(
'Undo/Redo handling'
,
(
)
=>
{
test
(
'Ignores undo changes'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
,
.
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
strictEqual
(
.
,
0
,
'Signal should not fire for undo changes'
)
;
}
)
;
test
(
'Ignores redo changes'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
,
.
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
strictEqual
(
.
,
0
,
'Signal should not fire for redo changes'
)
;
}
)
;
}
)
;
suite
(
'Edit timestamp limits'
,
(
)
=>
{
test
(
'No signal if edit is too old'
,
async
(
)
=>
{
const
{
}
=
createTextDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
)
;
.
strictEqual
(
TRIGGER_INLINE_EDIT_AFTER_CHANGE_LIMIT
,
10000
,
'Limit should be 10 seconds'
)
;
}
)
;
test
(
'Signal fires when edit is within time limit'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
isAtLeast
(
.
,
1
,
'Signal should fire for recent edits'
)
;
}
)
;
}
)
;
suite
(
'Trigger time checks'
,
(
)
=>
{
test
(
'No signal if last trigger time is too old'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_AFTER_CHANGE_LIMIT
-
1
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
strictEqual
(
.
,
0
,
'Signal should not fire when last trigger is too old'
)
;
}
)
;
test
(
'Signal fires when last trigger time is recent'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
.
=
.
now
(
)
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
isAtLeast
(
.
,
1
,
'Signal should fire for recent triggers'
)
;
}
)
;
}
)
;
suite
(
'Same line cooldown'
,
(
)
=>
{
test
(
'No signal for same line within cooldown period'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
const
=
.
;
.
isAtLeast
(
,
1
,
'First signal should fire'
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
10
,
0
,
10
)
)
;
.
strictEqual
(
.
,
,
'Signal should not fire for same line in cooldown'
)
;
}
)
;
test
(
'Signal fires on different line'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
undefined
,
undefined
,
'line1\nline2\nline3'
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
;
.
isAtLeast
(
,
1
,
'First signal should fire'
)
;
triggerTextSelectionChange
(
,
new
Selection
(
1
,
0
,
1
,
0
)
)
;
.
isAtLeast
(
.
,
+
1
,
'Signal should fire for different line'
)
;
}
)
;
test
(
'Cooldown constant is 5 seconds'
,
(
)
=>
{
.
strictEqual
(
TRIGGER_INLINE_EDIT_ON_SAME_LINE_COOLDOWN
,
5000
,
'Same line cooldown should be 5s'
)
;
}
)
;
}
)
;
suite
(
'Document switch behavior'
,
(
)
=>
{
test
(
'Triggers on document switch when configured'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
.
=
.
;
void
.
setConfig
(
.
.
,
30
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
const
=
.
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
.
isAtLeast
(
.
,
+
1
,
'Signal should fire on document switch'
)
;
.
strictEqual
(
getLastFiredReason
(
)
,
.
)
;
}
)
;
test
(
'Does not trigger on same document'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
void
.
setConfig
(
.
.
,
30
)
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
0
,
'Should not trigger document switch for same doc'
)
;
}
)
;
test
(
'Does not trigger when document switch is disabled'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
void
.
setConfig
(
.
.
,
undefined
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
0
,
'Should not trigger document switch when disabled'
)
;
}
)
;
test
(
'Does not trigger on document switch when there is no recent NES trigger (lastTriggerTime is 0)'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
.
=
0
;
void
.
setConfig
(
.
.
,
30
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
const
=
.
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
0
,
'Should not trigger document switch when lastTriggerTime is 0'
)
;
.
strictEqual
(
.
,
,
'No new events should fire'
)
;
}
)
;
test
(
'Does not trigger on document switch when NES trigger was too long ago'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
const
=
30
;
void
.
setConfig
(
.
.
,
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
const
=
.
;
.
=
.
now
(
)
-
(
*
1000
)
-
1
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
0
,
'Should not trigger document switch when last trigger was too long ago'
)
;
.
strictEqual
(
.
,
,
'No new events should fire'
)
;
}
)
;
test
(
'Triggers on document switch when NES trigger was recent'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
.
=
.
;
const
=
30
;
void
.
setConfig
(
.
.
,
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
const
=
.
;
.
=
.
now
(
)
-
(
*
1000
)
+
5000
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
1
,
'Should trigger document switch when last trigger was recent'
)
;
.
isAtLeast
(
.
,
+
1
,
'Should have fired an additional event'
)
;
}
)
;
}
)
;
suite
(
'Debounce behavior'
,
(
)
=>
{
test
(
'First two selection changes fire immediately when debounce is configured'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
undefined
,
undefined
,
'line1\nline2\nline3'
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
void
.
setConfig
(
.
.
,
100
)
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
.
strictEqual
(
.
,
1
,
'First selection change should fire immediately'
)
;
triggerTextSelectionChange
(
,
new
Selection
(
1
,
0
,
1
,
0
)
)
;
.
strictEqual
(
.
,
2
,
'Second selection change should fire immediately'
)
;
}
)
;
test
(
'Third and subsequent selection changes are debounced'
,
async
(
)
=>
{
const
{
,
}
=
createTextDocument
(
undefined
,
undefined
,
'line1\nline2\nline3\nline4\nline5'
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
const
=
50
;
void
.
setConfig
(
.
.
,
)
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
triggerTextSelectionChange
(
,
new
Selection
(
1
,
0
,
1
,
0
)
)
;
.
strictEqual
(
.
,
2
,
'First two should fire immediately'
)
;
triggerTextSelectionChange
(
,
new
Selection
(
2
,
0
,
2
,
0
)
)
;
.
strictEqual
(
.
,
2
,
'Third should not fire immediately'
)
;
await
new
Promise
(
=>
setTimeout
(
,
+
20
)
)
;
.
strictEqual
(
.
,
3
,
'Third should fire after debounce'
)
;
}
)
;
test
(
'No debounce when config is undefined'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
undefined
,
undefined
,
'line1\nline2\nline3\nline4'
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
void
.
setConfig
(
.
.
,
undefined
)
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
triggerTextSelectionChange
(
,
new
Selection
(
1
,
0
,
1
,
0
)
)
;
triggerTextSelectionChange
(
,
new
Selection
(
2
,
0
,
2
,
0
)
)
;
triggerTextSelectionChange
(
,
new
Selection
(
3
,
0
,
3
,
0
)
)
;
.
strictEqual
(
.
,
4
,
'All selection changes should fire immediately without debounce'
)
;
}
)
;
}
)
;
suite
(
'Event data validation'
,
(
)
=>
{
test
(
'Fired event has valid NesChangeHint structure'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
isAtLeast
(
.
,
1
,
'Should have fired at least one event'
)
;
const
=
[
0
]
;
.
isTrue
(
.
is
(
)
,
'Event should be a valid NesChangeHint'
)
;
.
isString
(
.
.
,
'UUID should be a string'
)
;
.
isNotEmpty
(
.
.
,
'UUID should not be empty'
)
;
.
strictEqual
(
.
.
,
.
)
;
}
)
;
test
(
'Each trigger has a unique UUID'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
undefined
,
undefined
,
'line1\nline2'
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
triggerTextSelectionChange
(
,
new
Selection
(
1
,
0
,
1
,
0
)
)
;
.
isAtLeast
(
.
,
2
,
'Should have at least 2 events'
)
;
const
=
.
map
(
=>
.
.
)
;
const
=
new
Set
(
)
;
.
strictEqual
(
.
,
.
,
'All UUIDs should be unique'
)
;
}
)
;
}
)
;
suite
(
'toRange returning undefined'
,
(
)
=>
{
test
(
'No signal when toRange returns undefined'
,
(
)
=>
{
const
=
.
file
(
'norange.py'
)
;
const
=
createTextDocumentData
(
,
'content'
,
'python'
)
;
const
=
new
Selection
(
0
,
0
,
0
,
0
)
;
const
=
new
ExtHostTextEditor
(
.
,
[
]
,
{
}
,
[
]
,
undefined
)
;
const
:
=
{
:
.
create
(
.
toString
(
)
)
,
toRange
:
(
)
=>
undefined
}
as
any
;
.
addDoc
(
.
,
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
strictEqual
(
.
,
0
,
'Signal should not fire when toRange returns undefined'
)
;
}
)
;
}
)
;
suite
(
'Notebook cell behavior'
,
(
)
=>
{
function
createNotebookCellDocument
(
:
string
=
'1'
,
=
'print("hello")'
)
:
{
:
;
:
}
{
const
=
.
parse
(
` vscode-notebook-cell://notebook/ ${ cellId} `
)
;
const
=
createTextDocumentData
(
,
,
'python'
)
;
const
=
new
Selection
(
0
,
0
,
0
,
0
)
;
const
=
new
ExtHostTextEditor
(
.
,
[
]
,
{
}
,
[
]
,
undefined
)
;
.
addDoc
(
.
,
createObservableTextDoc
(
.
.
)
)
;
return
{
:
.
,
:
.
}
;
}
test
(
'Notebook cell bypasses same-line cooldown when documentTrigger differs'
,
(
)
=>
{
const
=
createNotebookCellDocument
(
'cell1'
)
;
const
=
createNotebookCellDocument
(
'cell2'
,
'x = 1'
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
void
.
setConfig
(
.
.
,
undefined
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
;
.
isAtLeast
(
,
1
,
'First trigger should fire'
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
;
.
isAtLeast
(
,
+
1
,
'Should trigger in cell2 on line 0'
)
;
triggerTextChange
(
.
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
;
const
=
createNotebookCellDocument
(
'cell2'
,
'x = 1'
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
.
isAtLeast
(
.
,
+
1
,
'Should bypass same-line cooldown for notebook cell when documentTrigger differs'
)
;
}
)
;
test
(
'Notebook cell respects same-line cooldown when documentTrigger matches'
,
(
)
=>
{
const
=
createNotebookCellDocument
(
'cell1'
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
void
.
setConfig
(
.
.
,
undefined
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
;
.
isAtLeast
(
,
1
,
'First trigger should fire'
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
strictEqual
(
.
,
,
'Should respect same-line cooldown when documentTrigger matches'
)
;
}
)
;
}
)
;
suite
(
'Line trigger cleanup'
,
(
)
=>
{
test
(
'Stale line triggers are cleaned up when count exceeds 100'
,
(
)
=>
{
const
=
Array
.
from
(
{
:
110
}
,
(
,
)
=>
` line ${ i} `
)
.
join
(
'\n'
)
;
const
{
,
}
=
createTextDocument
(
undefined
,
undefined
,
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
)
;
for
(
let
=
0
;
<
101
;
++
)
{
triggerTextSelectionChange
(
,
new
Selection
(
,
0
,
,
0
)
)
;
}
.
strictEqual
(
.
,
101
,
'All 101 triggers should fire'
)
;
triggerTextSelectionChange
(
,
new
Selection
(
101
,
0
,
101
,
0
)
)
;
.
strictEqual
(
.
,
102
,
'Trigger should still work after cleanup runs'
)
;
}
)
;
}
)
;
suite
(
'Debounce edge cases'
,
(
)
=>
{
test
(
'New text change resets consecutive selection change counter'
,
async
(
)
=>
{
const
{
,
}
=
createTextDocument
(
undefined
,
undefined
,
'line1\nline2\nline3\nline4\nline5\nline6'
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
const
=
50
;
void
.
setConfig
(
.
.
,
)
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
triggerTextSelectionChange
(
,
new
Selection
(
1
,
0
,
1
,
0
)
)
;
triggerTextSelectionChange
(
,
new
Selection
(
2
,
0
,
2
,
0
)
)
;
.
strictEqual
(
.
,
2
,
'Third should be debounced'
)
;
await
new
Promise
(
=>
setTimeout
(
,
+
20
)
)
;
.
strictEqual
(
.
,
3
,
'Debounced event should fire'
)
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
3
,
0
,
3
,
0
)
)
;
.
strictEqual
(
.
,
4
,
'First selection after new change should fire immediately'
)
;
triggerTextSelectionChange
(
,
new
Selection
(
4
,
0
,
4
,
0
)
)
;
.
strictEqual
(
.
,
5
,
'Second selection after new change should fire immediately'
)
;
triggerTextSelectionChange
(
,
new
Selection
(
5
,
0
,
5
,
0
)
)
;
.
strictEqual
(
.
,
5
,
'Third selection after new change should be debounced again'
)
;
}
)
;
test
(
'Later debounced event replaces earlier pending one'
,
async
(
)
=>
{
const
=
Array
.
from
(
{
:
10
}
,
(
,
)
=>
` line ${ i} `
)
.
join
(
'\n'
)
;
const
{
,
}
=
createTextDocument
(
undefined
,
undefined
,
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
const
=
80
;
void
.
setConfig
(
.
.
,
)
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
triggerTextSelectionChange
(
,
new
Selection
(
1
,
0
,
1
,
0
)
)
;
.
strictEqual
(
.
,
2
)
;
triggerTextSelectionChange
(
,
new
Selection
(
2
,
0
,
2
,
0
)
)
;
.
strictEqual
(
.
,
2
,
'Third should be debounced'
)
;
triggerTextSelectionChange
(
,
new
Selection
(
3
,
0
,
3
,
0
)
)
;
.
strictEqual
(
.
,
2
,
'Fourth should also be debounced'
)
;
await
new
Promise
(
=>
setTimeout
(
,
+
30
)
)
;
.
strictEqual
(
.
,
3
,
'Only one debounced event should fire (the latest)'
)
;
}
)
;
}
)
;
suite
(
'Document switch edge cases'
,
(
)
=>
{
test
(
'Does not trigger on document switch to copilot-ignored destination'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
.
file
(
'ignored.py'
)
;
const
=
createTextDocumentData
(
,
'ignored content'
,
'python'
)
;
const
=
new
ExtHostTextEditor
(
.
,
[
new
Selection
(
0
,
0
,
0
,
0
)
]
,
{
}
,
[
]
,
undefined
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
void
.
setConfig
(
.
.
,
30
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
const
=
.
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
0
,
'Should not trigger switch for copilot-ignored destination'
)
;
.
strictEqual
(
.
,
,
'No new events should fire'
)
;
}
)
;
test
(
'Does not trigger on document switch when toRange returns undefined at destination'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
.
file
(
'norange2.py'
)
;
const
=
createTextDocumentData
(
,
'content'
,
'python'
)
;
const
=
new
ExtHostTextEditor
(
.
,
[
new
Selection
(
0
,
0
,
0
,
0
)
]
,
{
}
,
[
]
,
undefined
)
;
const
:
=
{
:
.
create
(
.
toString
(
)
)
,
toRange
:
(
)
=>
undefined
}
as
any
;
.
addDoc
(
.
,
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
void
.
setConfig
(
.
.
,
30
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
const
=
.
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
0
,
'Should not trigger switch when toRange returns undefined'
)
;
.
strictEqual
(
.
,
,
'No new events should fire'
)
;
}
)
;
test
(
'Does not trigger on document switch when no edit has ever happened'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
void
.
setConfig
(
.
.
,
30
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
0
,
'Should not trigger switch when no edits ever happened'
)
;
}
)
;
test
(
'Document switch adds doc to tracking map, enabling subsequent cursor moves to trigger'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
,
'line1\nline2'
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
.
=
.
;
void
.
setConfig
(
.
.
,
30
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
.
strictEqual
(
getLastFiredReason
(
)
,
.
)
;
const
=
.
;
triggerTextSelectionChange
(
.
,
new
Selection
(
1
,
0
,
1
,
0
)
)
;
.
isAtLeast
(
.
,
+
1
,
'Cursor move in switched-to doc should trigger'
)
;
.
strictEqual
(
getLastFiredReason
(
)
,
.
)
;
}
)
;
}
)
;
suite
(
'Document switch afterAcceptance strategy'
,
(
)
=>
{
function
setupForDocSwitch
(
)
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
void
.
setConfig
(
.
.
,
30
)
;
void
.
setConfig
(
.
.
,
.
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
return
{
,
,
:
.
}
;
}
test
(
'triggers on document switch when lastOutcome is Accepted'
,
(
)
=>
{
const
{
,
}
=
setupForDocSwitch
(
)
;
.
=
.
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
1
,
'Should trigger document switch after acceptance'
)
;
.
isAbove
(
.
,
)
;
}
)
;
test
(
'does not trigger on document switch when lastOutcome is Rejected'
,
(
)
=>
{
const
{
,
}
=
setupForDocSwitch
(
)
;
.
=
.
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
0
,
'Should not trigger document switch after rejection'
)
;
.
strictEqual
(
.
,
)
;
}
)
;
test
(
'does not trigger on document switch when lastOutcome is Ignored'
,
(
)
=>
{
const
{
,
}
=
setupForDocSwitch
(
)
;
.
=
.
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
0
,
'Should not trigger document switch after ignore'
)
;
.
strictEqual
(
.
,
)
;
}
)
;
test
(
'does not trigger on document switch when lastOutcome is undefined (pending)'
,
(
)
=>
{
const
{
,
}
=
setupForDocSwitch
(
)
;
.
=
undefined
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
0
,
'Should not trigger document switch when outcome is pending'
)
;
.
strictEqual
(
.
,
)
;
}
)
;
test
(
'triggers on document switch with default strategy regardless of lastOutcome'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
void
.
setConfig
(
.
.
,
30
)
;
void
.
setConfig
(
.
.
,
.
)
;
.
=
.
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
const
=
.
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
1
,
'Default strategy should trigger on doc switch regardless of outcome'
)
;
.
isAbove
(
.
,
)
;
}
)
;
test
(
'triggers on document switch with always strategy regardless of lastOutcome'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
void
.
setConfig
(
.
.
,
30
)
;
void
.
setConfig
(
.
.
,
.
)
;
.
=
.
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
const
=
.
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
1
,
'Always strategy should trigger on doc switch regardless of outcome'
)
;
.
isAbove
(
.
,
)
;
}
)
;
suite
(
'race condition: suggestion shown but not yet resolved'
,
(
)
=>
{
test
(
'previous NES was accepted, new suggestion shown (clears outcome), then doc switch — should NOT trigger'
,
(
)
=>
{
const
{
,
}
=
setupForDocSwitch
(
)
;
.
=
.
;
.
=
undefined
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
0
,
'Should not trigger: stale acceptance must not carry over when a new suggestion is pending'
)
;
.
strictEqual
(
.
,
)
;
}
)
;
test
(
'NES shown, then accepted, then doc switch — should trigger'
,
(
)
=>
{
const
{
}
=
setupForDocSwitch
(
)
;
.
=
undefined
;
.
=
.
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
1
,
'Should trigger after resolved acceptance'
)
;
}
)
;
test
(
'NES shown, then rejected, then doc switch — should NOT trigger'
,
(
)
=>
{
const
{
,
}
=
setupForDocSwitch
(
)
;
.
=
undefined
;
.
=
.
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
0
,
'Should not trigger after resolved rejection'
)
;
.
strictEqual
(
.
,
)
;
}
)
;
}
)
;
}
)
;
suite
(
'Text change listener edge cases'
,
(
)
=>
{
test
(
'Text change on copilot-ignored doc does not track but updates lastEditTimestamp'
,
(
)
=>
{
const
=
.
file
(
'ignored.py'
)
;
const
=
createTextDocumentData
(
,
'content'
,
'python'
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'tracked.py'
)
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
void
.
setConfig
(
.
.
,
30
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'tracked2.py'
)
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
.
isTrue
(
true
,
'Test verifies that ignored doc change does not throw'
)
;
}
)
;
test
(
'Undo/redo still updates lastEditTimestamp (only skips tracking)'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
.
=
.
;
void
.
setConfig
(
.
.
,
30
)
;
triggerTextChange
(
.
,
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
isAtLeast
(
.
,
1
,
'Undo should still update lastEditTimestamp enabling document switch'
)
;
}
)
;
test
(
'Output pane text change does not update lastEditTimestamp'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
)
;
const
{
:
}
=
createOutputDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
void
.
setConfig
(
.
.
,
30
)
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
filter
(
=>
.
.
===
.
)
;
.
strictEqual
(
.
,
0
,
'Output doc change should not update lastEditTimestamp'
)
;
}
)
;
}
)
;
suite
(
'Interaction edge cases'
,
(
)
=>
{
test
(
'Rejection cooldown prevents document switch triggers too'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
)
;
.
=
.
now
(
)
;
void
.
setConfig
(
.
.
,
30
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
strictEqual
(
.
,
0
,
'Should not fire during rejection cooldown'
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
.
strictEqual
(
.
,
0
,
'Should not fire on doc switch during rejection cooldown'
)
;
}
)
;
test
(
'Same-line cooldown is bypassed after switching away and back'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
const
=
.
;
.
isAtLeast
(
,
1
,
'First trigger should fire'
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
10
,
0
,
10
)
)
;
.
strictEqual
(
.
,
,
'Same-line cooldown should block'
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
10
,
0
,
10
)
)
;
.
isAtLeast
(
.
,
+
1
,
'Same-line cooldown should be bypassed after switching away and back'
)
;
}
)
;
test
(
'Output pane documents are ignored for selection changes'
,
(
)
=>
{
const
{
,
}
=
createOutputDocument
(
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextSelectionChange
(
,
)
;
.
strictEqual
(
.
,
0
,
'Selection in output pane should be ignored'
)
;
}
)
;
test
(
'Copilot-ignored doc in selection listener returns early before rejection check'
,
(
)
=>
{
const
=
.
file
(
'not-in-workspace.py'
)
;
const
=
createTextDocumentData
(
,
'content'
,
'python'
)
;
const
=
new
ExtHostTextEditor
(
.
,
[
new
Selection
(
0
,
0
,
0
,
0
)
]
,
{
}
,
[
]
,
undefined
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
strictEqual
(
.
,
0
,
'Copilot-ignored doc should return early in selection listener'
)
;
}
)
;
test
(
'Multiple documents can independently track and trigger'
,
(
)
=>
{
const
=
createTextDocument
(
undefined
,
.
file
(
'file1.py'
)
,
'line1\nline2'
)
;
const
=
createTextDocument
(
undefined
,
.
file
(
'file2.py'
)
,
'line1\nline2'
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
.
strictEqual
(
.
,
1
,
'Doc1 first trigger'
)
;
triggerTextChange
(
.
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
.
strictEqual
(
.
,
2
,
'Doc2 first trigger'
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
1
,
0
,
1
,
0
)
)
;
.
strictEqual
(
.
,
3
,
'Doc1 second trigger on different line'
)
;
triggerTextSelectionChange
(
.
,
new
Selection
(
1
,
0
,
1
,
0
)
)
;
.
strictEqual
(
.
,
4
,
'Doc2 second trigger on different line'
)
;
}
)
;
test
(
'Text change resets line triggers for the document'
,
(
)
=>
{
const
{
,
}
=
createTextDocument
(
undefined
,
undefined
,
'line1\nline2'
)
;
.
=
.
now
(
)
-
TRIGGER_INLINE_EDIT_REJECTION_COOLDOWN
-
1
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
const
=
.
;
.
isAtLeast
(
,
1
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
5
,
0
,
5
)
)
;
.
strictEqual
(
.
,
,
'Same line should be in cooldown'
)
;
triggerTextChange
(
)
;
triggerTextSelectionChange
(
,
new
Selection
(
0
,
0
,
0
,
0
)
)
;
.
isAtLeast
(
.
,
+
1
,
'After text change, same line should trigger again'
)
;
}
)
;
}
)
;
}
)
;