ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / editor / contrib / snippet / test / browser / snippetController2.test.ts 784 строк · изменён 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
import assert from 'assert' ;
import { mock } from '../../../../../base/test/common/mock.js' ;
import { CoreEditingCommands } from '../../../../browser/coreCommands.js' ;
import { ICodeEditor } from '../../../../browser/editorBrowser.js' ;
import { Selection } from '../../../../common/core/selection.js' ;
import { Range } from '../../../../common/core/range.js' ;
import { Handler } from '../../../../common/editorCommon.js' ;
import { TextModel } from '../../../../common/model/textModel.js'
SnippetController2
createTestCodeEditor ITestCodeEditor
createTextModel
IContextKeyService
IInstantiationService
InstantiationService
ServiceCollection
MockContextKeyService
ILabelService
ILogService NullLogService
IWorkspaceContextService
EndOfLineSequence
ensureNoDisposablesAreLeakedInTestSuite
editor ICodeEditor s Selection
selection editor
actual s
assert selection actual
assert s length
service MockContextKeyService inSnippet hasPrev hasNext
state service
assert state inSnippet inSnippet
assert state hasPrev hasPrev
assert state hasNext hasNext
service MockContextKeyService contextKeys
inSnippet SnippetController2 InSnippetMode service
hasPrev SnippetController2 HasPrevTabstop service
hasNext SnippetController2 HasNextTabstop service
ctrl SnippetController2
editor ITestCodeEditor
model TextModel
contextKeys MockContextKeyService
instaService IInstantiationService
contextKeys
model
serviceCollection
ILabelService
IWorkspaceContextService
override
id folders
ILogService
IContextKeyService contextKeys
instaService serviceCollection
editor model serviceCollection
editor
assert model
model
ctrl
ctrl instaService SnippetController2 editor
contextKeys
ctrl instaService SnippetController2 editor
ctrl
contextKeys
editor
ctrl
contextKeys
editor
ctrl instaService SnippetController2 editor
ctrl
contextKeys
ctrl
contextKeys
ctrl
contextKeys
editor text
assert SnippetController2 InSnippetMode contextKeys
assert SnippetController2 HasNextTabstop contextKeys
assert SnippetController2 HasPrevTabstop contextKeys
ctrl instaService SnippetController2 editor
ctrl
contextKeys
editor
editor
contextKeys
ctrl instaService SnippetController2 editor
ctrl
contextKeys
editor
editor
contextKeys
ctrl instaService SnippetController2 editor
ctrl
assert SnippetController2 InSnippetMode contextKeys
editor
editor
contextKeys
ctrl instaService SnippetController2 editor
ctrl
contextKeys
editor
ctrl instaService SnippetController2 editor
ctrl
contextKeys
editor
editor
contextKeys
editor
editor text
contextKeys
ctrl
contextKeys
editor
contextKeys
ctrl instaService SnippetController2 editor
ctrl
contextKeys
editor
ctrl
editor
contextKeys
ctrl
editor
contextKeys
ctrl instaService SnippetController2 editor
ctrl
contextKeys
editor
ctrl
editor
contextKeys
ctrl
editor
contextKeys
ctrl
editor
contextKeys
ctrl instaService SnippetController2 editor
ctrl
contextKeys
editor
ctrl
editor
contextKeys
ctrl
editor
contextKeys
ctrl instaService SnippetController2 editor
ctrl
contextKeys
editor
ctrl
contextKeys
editor
ctrl
contextKeys
editor
ctrl
contextKeys
ctrl instaService SnippetController2 editor
ctrl
contextKeys
editor
ctrl
editor
ctrl
editor
ctrl
editor
ctrl
editor
ctrl
editor
ctrl instaService SnippetController2 editor
model
editor
ctrl
contextKeys
editor
ctrl
editor
ctrl
editor
ctrl instaService SnippetController2 editor
model
model insertSpaces tabSize trimAutoWhitespace
editor
ctrl
ctrl
ctrl
ctrl
ctrl
editor
ctrl
editor
ctrl instaService SnippetController2 editor
model
editor
ctrl
editor
editor
contextKeys
ctrl instaService SnippetController2 editor
model
editor
ctrl
editor
contextKeys
ctrl instaService SnippetController2 editor
model
editor
ctrl
editor
contextKeys
ctrl
contextKeys
ctrl instaService SnippetController2 editor
model
editor
ctrl
editor
contextKeys
ctrl
editor
ctrl
editor
ctrl
editor
ctrl
editor
ctrl
editor
ctrl
editor
contextKeys
ctrl instaService SnippetController2 editor
model
editor
ctrl
editor
editor Handler Cut
editor
ctrl
editor
contextKeys
ctrl instaService SnippetController2 editor
model
editor
ctrl
editor
ctrl
editor
contextKeys
editor
contextKeys
editor
contextKeys
editor
ctrl instaService SnippetController2 editor
model
editor
ctrl
editor
ctrl
editor
contextKeys
editor
contextKeys
ctrl
contextKeys
editor
ctrl instaService SnippetController2 editor
model
editor
ctrl
contextKeys
ctrl instaService SnippetController2 editor
model
editor
ctrl
contextKeys
editor
editor Handler Cut
editor
ctrl
editor
contextKeys
ctrl instaService SnippetController2 editor
model
editor CoreEditingCommands Tab
ctrl
editor
ctrl instaService SnippetController2 editor
model
editor CoreEditingCommands Tab
ctrl adjustWhitespace
editor
ctrl instaService SnippetController2 editor
model
editor CoreEditingCommands Tab
ctrl
editor
ctrl instaService SnippetController2 editor
model
model insertSpaces tabSize
ctrl
assert model
ctrl instaService SnippetController2 editor
model
model insertSpaces tabSize
ctrl
assert model
test
ctrl instaService SnippetController2 editor
model
model insertSpaces tabSize
ctrl
editor
editor text
ctrl
assert model
ctrl instaService SnippetController2 editor
model
model insertSpaces tabSize
ctrl
editor
editor text
ctrl
ctrl
assert model
ctrl instaService SnippetController2 editor
model
range template
range template
assert model
contextKeys
assert editor
ctrl
contextKeys
assert editor
model
ctrl instaService SnippetController2 editor
range template
range template
assert model
contextKeys
assert editor
ctrl
contextKeys
assert editor
model
ctrl instaService SnippetController2 editor
range template
range template
range template
assert model
assert inSnippet hasPrev hasNext
assert editor
ctrl
assert inSnippet hasPrev hasNext
assert editor
ctrl
assert inSnippet hasPrev hasNext
assert editor
ctrl instaService SnippetController2 editor
model
editor
range
template
assert model
assert inSnippet hasPrev hasNext
assert editor
ctrl
assert model
assert editor
assert inSnippet hasPrev hasNext
ctrl
assert inSnippet hasPrev hasNext
assert editor
ctrl
assert inSnippet hasPrev hasNext
assert editor
ctrl instaService SnippetController2 editor
model
editor
ctrl
assert editor
assert inSnippet hasPrev hasNext
range
template
assert model
assert inSnippet hasPrev hasNext
assert editor
ctrl instaService SnippetController2 editor
model
editor
ctrl
assert editor
assert inSnippet hasPrev hasNext
edits
range
template
range
template
range
template
range
template
edits
assert model
assert inSnippet hasPrev hasNext
assert editor
ctrl instaService SnippetController2 editor
model
ctrl
assert editor
ctrl
assert model
assert editor
ctrl instaService SnippetController2 editor
model
model EndOfLineSequence
range model
template
assert editor
model
sel
editor sel
ctrl instaService SnippetController2 editor
range sel
template
assert model
model
ranges
editor ranges r r startLineNumber r startColumn r endLineNumber r endColumn
ctrl instaService SnippetController2 editor
ranges range range template
assert model
model
ctrl instaService SnippetController2 editor
range template
range template
range template
assert model
model
editor
ctrl instaService SnippetController2 editor
range template
assert model
editor CoreEditingCommands Undo
assert model
assert editor
;
import
{
}
from
'../../browser/snippetController2.js'
;
import
{
,
}
from
'../../../../test/browser/testCodeEditor.js'
;
import
{
}
from
'../../../../test/common/testTextModel.js'
;
import
{
}
from
'../../../../../platform/contextkey/common/contextkey.js'
;
import
{
}
from
'../../../../../platform/instantiation/common/instantiation.js'
;
import
{
}
from
'../../../../../platform/instantiation/common/instantiationService.js'
;
import
{
}
from
'../../../../../platform/instantiation/common/serviceCollection.js'
;
import
{
}
from
'../../../../../platform/keybinding/test/common/mockKeybindingService.js'
;
import
{
}
from
'../../../../../platform/label/common/label.js'
;
import
{
,
}
from
'../../../../../platform/log/common/log.js'
;
import
{
}
from
'../../../../../platform/workspace/common/workspace.js'
;
import
{
}
from
'../../../../common/model.js'
;
import
{
}
from
'../../../../../base/test/common/utils.js'
;
suite
(
'SnippetController2'
,
function
(
)
{
function
assertSelections
(
:
,
...
:
[
]
)
{
for
(
const
of
.
getSelections
(
)
!
)
{
const
=
.
shift
(
)
!
;
.
ok
(
.
equalsSelection
(
)
,
` actual= ${ selection. toString ( ) } <> expected= ${ actual. toString ( ) } `
)
;
}
.
strictEqual
(
.
,
0
)
;
}
function
assertContextKeys
(
:
,
:
boolean
,
:
boolean
,
:
boolean
)
:
void
{
const
=
getContextState
(
)
;
.
strictEqual
(
.
,
,
` inSnippetMode `
)
;
.
strictEqual
(
.
,
,
` HasPrevTabstop `
)
;
.
strictEqual
(
.
,
,
` HasNextTabstop `
)
;
}
function
getContextState
(
:
=
)
{
return
{
:
.
.
getValue
(
)
,
:
.
.
getValue
(
)
,
:
.
.
getValue
(
)
,
}
;
}
let
:
;
let
:
;
let
:
;
let
:
;
let
:
;
setup
(
function
(
)
{
=
new
MockContextKeyService
(
)
;
=
createTextModel
(
'if\n $state\nfi'
)
;
const
=
new
ServiceCollection
(
[
,
new
class
extends
mock< ILabelService>
(
)
{
}
]
,
[
,
new
class
extends
mock< IWorkspaceContextService>
(
)
{
getWorkspace
(
)
{
return
{
:
'foo'
,
:
[
]
}
;
}
}
]
,
[
,
new
NullLogService
(
)
]
,
[
,
]
,
)
;
=
new
InstantiationService
(
)
;
=
createTestCodeEditor
(
,
{
}
)
;
.
setSelections
(
[
new
Selection
(
1
,
1
,
1
,
1
)
,
new
Selection
(
2
,
5
,
2
,
5
)
]
)
;
.
strictEqual
(
.
getEOL
(
)
,
'\n'
)
;
}
)
;
teardown
(
function
(
)
{
.
dispose
(
)
;
.
dispose
(
)
;
}
)
;
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
test
(
'creation'
,
(
)
=>
{
=
.
createInstance
(
,
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
}
)
;
test
(
'insert, insert -> abort'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
insert
(
'foo${1:bar}foo$0'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
4
,
1
,
7
)
,
new
Selection
(
2
,
8
,
2
,
11
)
)
;
.
cancel
(
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
assertSelections
(
,
new
Selection
(
1
,
4
,
1
,
7
)
,
new
Selection
(
2
,
8
,
2
,
11
)
)
;
}
)
;
test
(
'insert, insert -> tab, tab, done'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
insert
(
'${1:one}${2:two}$0'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
.
next
(
)
;
assertContextKeys
(
,
true
,
true
,
true
)
;
.
next
(
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
.
trigger
(
'test'
,
'type'
,
{
:
'\t'
}
)
;
.
strictEqual
(
.
.
getValue
(
)
,
false
)
;
.
strictEqual
(
.
.
getValue
(
)
,
false
)
;
.
strictEqual
(
.
.
getValue
(
)
,
false
)
;
}
)
;
test
(
'insert, insert -> cursor moves out (left/right)'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
insert
(
'foo${1:bar}foo$0'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
4
,
1
,
7
)
,
new
Selection
(
2
,
8
,
2
,
11
)
)
;
.
setSelections
(
[
new
Selection
(
1
,
12
,
1
,
12
)
,
new
Selection
(
2
,
16
,
2
,
16
)
]
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
}
)
;
test
(
'insert, insert -> cursor moves out (up/down)'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
insert
(
'foo${1:bar}foo$0'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
4
,
1
,
7
)
,
new
Selection
(
2
,
8
,
2
,
11
)
)
;
.
setSelections
(
[
new
Selection
(
2
,
4
,
2
,
7
)
,
new
Selection
(
3
,
8
,
3
,
11
)
]
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
}
)
;
test
(
'insert, insert -> cursors collapse'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
insert
(
'foo${1:bar}foo$0'
)
;
.
strictEqual
(
.
.
getValue
(
)
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
4
,
1
,
7
)
,
new
Selection
(
2
,
8
,
2
,
11
)
)
;
.
setSelections
(
[
new
Selection
(
1
,
4
,
1
,
7
)
]
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
}
)
;
test
(
'insert, insert plain text -> no snippet mode'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
insert
(
'foobar'
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
assertSelections
(
,
new
Selection
(
1
,
7
,
1
,
7
)
,
new
Selection
(
2
,
11
,
2
,
11
)
)
;
}
)
;
test
(
'insert, delete snippet text'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
insert
(
'${1:foobar}$0'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
1
,
1
,
7
)
,
new
Selection
(
2
,
5
,
2
,
11
)
)
;
.
trigger
(
'test'
,
'cut'
,
{
}
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
1
,
1
,
1
)
,
new
Selection
(
2
,
5
,
2
,
5
)
)
;
.
trigger
(
'test'
,
'type'
,
{
:
'abc'
}
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
.
next
(
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
.
trigger
(
'test'
,
'tab'
,
{
}
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
}
)
;
test
(
'insert, nested trivial snippet'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
insert
(
'${1:foo}bar$0'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
1
,
1
,
4
)
,
new
Selection
(
2
,
5
,
2
,
8
)
)
;
.
insert
(
'FOO$0'
)
;
assertSelections
(
,
new
Selection
(
1
,
4
,
1
,
4
)
,
new
Selection
(
2
,
8
,
2
,
8
)
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
7
,
1
,
7
)
,
new
Selection
(
2
,
11
,
2
,
11
)
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
}
)
;
test
(
'insert, nested snippet'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
insert
(
'${1:foobar}$0'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
1
,
1
,
7
)
,
new
Selection
(
2
,
5
,
2
,
11
)
)
;
.
insert
(
'far$1boo$0'
)
;
assertSelections
(
,
new
Selection
(
1
,
4
,
1
,
4
)
,
new
Selection
(
2
,
8
,
2
,
8
)
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
7
,
1
,
7
)
,
new
Selection
(
2
,
11
,
2
,
11
)
)
;
assertContextKeys
(
,
true
,
true
,
true
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
7
,
1
,
7
)
,
new
Selection
(
2
,
11
,
2
,
11
)
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
}
)
;
test
(
'insert, nested plain text'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
insert
(
'${1:foobar}$0'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
1
,
1
,
7
)
,
new
Selection
(
2
,
5
,
2
,
11
)
)
;
.
insert
(
'farboo'
)
;
assertSelections
(
,
new
Selection
(
1
,
7
,
1
,
7
)
,
new
Selection
(
2
,
11
,
2
,
11
)
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
7
,
1
,
7
)
,
new
Selection
(
2
,
11
,
2
,
11
)
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
}
)
;
test
(
'Nested snippets without final placeholder jumps to next outer placeholder, #27898'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
insert
(
'for(const ${1:element} of ${2:array}) {$0}'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
11
,
1
,
18
)
,
new
Selection
(
2
,
15
,
2
,
22
)
)
;
.
next
(
)
;
assertContextKeys
(
,
true
,
true
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
22
,
1
,
27
)
,
new
Selection
(
2
,
26
,
2
,
31
)
)
;
.
insert
(
'document'
)
;
assertContextKeys
(
,
true
,
true
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
30
,
1
,
30
)
,
new
Selection
(
2
,
34
,
2
,
34
)
)
;
.
next
(
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
}
)
;
test
(
'Inconsistent tab stop behaviour with recursive snippets and tab / shift tab, #27543'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
insert
(
'1_calize(${1:nl}, \'${2:value}\')$0'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
10
,
1
,
12
)
,
new
Selection
(
2
,
14
,
2
,
16
)
)
;
.
insert
(
'2_calize(${1:nl}, \'${2:value}\')$0'
)
;
assertSelections
(
,
new
Selection
(
1
,
19
,
1
,
21
)
,
new
Selection
(
2
,
23
,
2
,
25
)
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
24
,
1
,
29
)
,
new
Selection
(
2
,
28
,
2
,
33
)
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
31
,
1
,
31
)
,
new
Selection
(
2
,
35
,
2
,
35
)
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
34
,
1
,
39
)
,
new
Selection
(
2
,
38
,
2
,
43
)
)
;
.
prev
(
)
;
assertSelections
(
,
new
Selection
(
1
,
31
,
1
,
31
)
,
new
Selection
(
2
,
35
,
2
,
35
)
)
;
}
)
;
test
(
'Snippet tabstop selecting content of previously entered variable only works when separated by space, #23728'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
setSelection
(
new
Selection
(
1
,
1
,
1
,
1
)
)
;
.
insert
(
'import ${2:${1:module}} from \'${1:module}\'$0'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
8
,
1
,
14
)
,
new
Selection
(
1
,
21
,
1
,
27
)
)
;
.
insert
(
'foo'
)
;
assertSelections
(
,
new
Selection
(
1
,
11
,
1
,
11
)
,
new
Selection
(
1
,
21
,
1
,
21
)
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
8
,
1
,
11
)
)
;
}
)
;
test
(
'HTML Snippets Combine, #32211'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
updateOptions
(
{
:
false
,
:
4
,
:
false
}
)
;
.
setSelection
(
new
Selection
(
1
,
1
,
1
,
1
)
)
;
.
insert
(
`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=\${2:device-width}, initial-scale=\${3:1.0}">
<meta http-equiv="X-UA-Compatible" content="\${5:ie=edge}">
<title>\${7:Document}</title>
</head>
<body>
\${8}
</body>
</html>
`
)
;
.
next
(
)
;
.
next
(
)
;
.
next
(
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
11
,
5
,
11
,
5
)
)
;
.
insert
(
'<input type="${2:text}">'
)
;
assertSelections
(
,
new
Selection
(
11
,
18
,
11
,
22
)
)
;
}
)
;
test
(
'Problems with nested snippet insertion #39594'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
setSelection
(
new
Selection
(
1
,
1
,
1
,
1
)
)
;
.
insert
(
'$1 = ConvertTo-Json $1'
)
;
assertSelections
(
,
new
Selection
(
1
,
1
,
1
,
1
)
,
new
Selection
(
1
,
19
,
1
,
19
)
)
;
.
setSelection
(
new
Selection
(
1
,
19
,
1
,
19
)
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
}
)
;
test
(
'Problems with nested snippet insertion #39594 (part2)'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
'a-\naaa-'
)
;
.
setSelections
(
[
new
Selection
(
2
,
5
,
2
,
5
)
,
new
Selection
(
1
,
3
,
1
,
3
)
]
)
;
.
insert
(
'log($1);$0'
)
;
assertSelections
(
,
new
Selection
(
2
,
9
,
2
,
9
)
,
new
Selection
(
1
,
7
,
1
,
7
)
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
}
)
;
test
(
'“Nested” snippets terminating abruptly in VSCode 1.19.2. #42012'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
setSelection
(
new
Selection
(
1
,
1
,
1
,
1
)
)
;
.
insert
(
'var ${2:${1:name}} = ${1:name} + 1;${0}'
)
;
assertSelections
(
,
new
Selection
(
1
,
5
,
1
,
9
)
,
new
Selection
(
1
,
12
,
1
,
16
)
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
.
next
(
)
;
assertContextKeys
(
,
true
,
true
,
true
)
;
}
)
;
test
(
'Placeholders order #58267'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
setSelection
(
new
Selection
(
1
,
1
,
1
,
1
)
)
;
.
insert
(
'\\pth{$1}$0'
)
;
assertSelections
(
,
new
Selection
(
1
,
6
,
1
,
6
)
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
.
insert
(
'\\itv{${1:left}}{${2:right}}{${3:left_value}}{${4:right_value}}$0'
)
;
assertSelections
(
,
new
Selection
(
1
,
11
,
1
,
15
)
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
17
,
1
,
22
)
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
24
,
1
,
34
)
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
36
,
1
,
47
)
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
48
,
1
,
48
)
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
49
,
1
,
49
)
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
}
)
;
test
(
'Must tab through deleted tab stops in snippets #31619'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
setSelection
(
new
Selection
(
1
,
1
,
1
,
1
)
)
;
.
insert
(
'foo${1:a${2:bar}baz}end$0'
)
;
assertSelections
(
,
new
Selection
(
1
,
4
,
1
,
11
)
)
;
.
trigger
(
'test'
,
.
,
null
)
;
assertSelections
(
,
new
Selection
(
1
,
4
,
1
,
4
)
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
7
,
1
,
7
)
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
}
)
;
test
(
'Cancelling snippet mode should discard added cursors #68512 (soft cancel)'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
setSelection
(
new
Selection
(
1
,
1
,
1
,
1
)
)
;
.
insert
(
'.REGION ${2:FUNCTION_NAME}\nCREATE.FUNCTION ${1:VOID} ${2:FUNCTION_NAME}(${3:})\n\t${4:}\nEND\n.ENDREGION$0'
)
;
assertSelections
(
,
new
Selection
(
2
,
17
,
2
,
21
)
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
9
,
1
,
22
)
,
new
Selection
(
2
,
22
,
2
,
35
)
)
;
assertContextKeys
(
,
true
,
true
,
true
)
;
.
setSelections
(
[
new
Selection
(
1
,
22
,
1
,
22
)
,
new
Selection
(
2
,
35
,
2
,
35
)
]
)
;
assertContextKeys
(
,
true
,
true
,
true
)
;
.
setSelections
(
[
new
Selection
(
2
,
1
,
2
,
1
)
,
new
Selection
(
2
,
36
,
2
,
36
)
]
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
assertSelections
(
,
new
Selection
(
2
,
1
,
2
,
1
)
,
new
Selection
(
2
,
36
,
2
,
36
)
)
;
}
)
;
test
(
'Cancelling snippet mode should discard added cursors #68512 (hard cancel)'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
setSelection
(
new
Selection
(
1
,
1
,
1
,
1
)
)
;
.
insert
(
'.REGION ${2:FUNCTION_NAME}\nCREATE.FUNCTION ${1:VOID} ${2:FUNCTION_NAME}(${3:})\n\t${4:}\nEND\n.ENDREGION$0'
)
;
assertSelections
(
,
new
Selection
(
2
,
17
,
2
,
21
)
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
1
,
9
,
1
,
22
)
,
new
Selection
(
2
,
22
,
2
,
35
)
)
;
assertContextKeys
(
,
true
,
true
,
true
)
;
.
setSelections
(
[
new
Selection
(
1
,
22
,
1
,
22
)
,
new
Selection
(
2
,
35
,
2
,
35
)
]
)
;
assertContextKeys
(
,
true
,
true
,
true
)
;
.
cancel
(
true
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
assertSelections
(
,
new
Selection
(
1
,
22
,
1
,
22
)
)
;
}
)
;
test
(
'User defined snippet tab stops ignored #72862'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
setSelection
(
new
Selection
(
1
,
1
,
1
,
1
)
)
;
.
insert
(
'export default $1'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
}
)
;
test
(
'Optional tabstop in snippets #72358'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
setSelection
(
new
Selection
(
1
,
1
,
1
,
1
)
)
;
.
insert
(
'${1:prop: {$2\\},}\nmore$0'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
assertSelections
(
,
new
Selection
(
1
,
1
,
1
,
10
)
)
;
.
trigger
(
'test'
,
.
,
{
}
)
;
assertSelections
(
,
new
Selection
(
1
,
1
,
1
,
1
)
)
;
.
next
(
)
;
assertSelections
(
,
new
Selection
(
2
,
5
,
2
,
5
)
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
}
)
;
test
(
'issue #90135: confusing trim whitespace edits'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
runCommand
(
.
,
null
)
;
.
insert
(
'\nfoo'
)
;
assertSelections
(
,
new
Selection
(
2
,
8
,
2
,
8
)
)
;
}
)
;
test
(
'issue #145727: insertSnippet can put snippet selections in wrong positions (1 of 2)'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
runCommand
(
.
,
null
)
;
.
insert
(
'\naProperty: aClass<${2:boolean}> = new aClass<${2:boolean}>();\n'
,
{
:
false
}
)
;
assertSelections
(
,
new
Selection
(
2
,
19
,
2
,
26
)
,
new
Selection
(
2
,
41
,
2
,
48
)
)
;
}
)
;
test
(
'issue #145727: insertSnippet can put snippet selections in wrong positions (2 of 2)'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
runCommand
(
.
,
null
)
;
.
insert
(
'\naProperty: aClass<${2:boolean}> = new aClass<${2:boolean}>();\n'
)
;
assertSelections
(
,
new
Selection
(
2
,
23
,
2
,
30
)
,
new
Selection
(
2
,
45
,
2
,
52
)
)
;
}
)
;
test
(
'leading TAB by snippets won\'t replace by spaces #101870'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
updateOptions
(
{
:
true
,
:
4
}
)
;
.
insert
(
'\tHello World\n\tNew Line'
)
;
.
strictEqual
(
.
getValue
(
)
,
' Hello World\n New Line'
)
;
}
)
;
test
(
'leading TAB by snippets won\'t replace by spaces #101870 (part 2)'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
updateOptions
(
{
:
true
,
:
4
}
)
;
.
insert
(
'\tHello World\n\tNew Line\n${1:\tmore}'
)
;
.
strictEqual
(
.
getValue
(
)
,
' Hello World\n New Line\n more'
)
;
}
)
;
.
skip
(
'Snippet transformation does not work after inserting variable using intellisense, #112362'
,
function
(
)
{
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
updateOptions
(
{
:
true
,
:
4
}
)
;
.
insert
(
'$1\n\n${1/([A-Za-z0-9]+): ([A-Za-z]+).*/$1: \'$2\',/gm}'
)
;
assertSelections
(
,
new
Selection
(
1
,
1
,
1
,
1
)
,
new
Selection
(
3
,
1
,
3
,
1
)
)
;
.
trigger
(
'test'
,
'type'
,
{
:
'foo: number;'
}
)
;
.
next
(
)
;
.
strictEqual
(
.
getValue
(
)
,
` foo: number;\n\nfoo: 'number', `
)
;
}
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
updateOptions
(
{
:
true
,
:
4
}
)
;
.
insert
(
'$1\n\n${1/([A-Za-z0-9]+): ([A-Za-z]+).*/$1: \'$2\',/gm}'
)
;
assertSelections
(
,
new
Selection
(
1
,
1
,
1
,
1
)
,
new
Selection
(
3
,
1
,
3
,
1
)
)
;
.
trigger
(
'test'
,
'type'
,
{
:
'foo: '
}
)
;
.
insert
(
'number;'
)
;
.
next
(
)
;
.
strictEqual
(
.
getValue
(
)
,
` foo: number;\n\nfoo: 'number', `
)
;
}
)
;
suite
(
'createEditsAndSnippetsFromEdits'
,
function
(
)
{
test
(
'apply, tab, done'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
'foo("bar")'
)
;
ctrl
.
apply
(
[
{
:
new
Range
(
1
,
5
,
1
,
10
)
,
:
'$1'
}
,
{
:
new
Range
(
1
,
1
,
1
,
1
)
,
:
'const ${1:new_const} = "bar";\n'
}
]
)
;
.
strictEqual
(
.
getValue
(
)
,
'const new_const = "bar";\nfoo(new_const)'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
7
,
1
,
16
)
,
new
Selection
(
2
,
5
,
2
,
14
)
]
)
;
.
next
(
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
2
,
14
,
2
,
14
)
]
)
;
}
)
;
test
(
'apply, tab, done with special final tabstop'
,
function
(
)
{
.
setValue
(
'foo("bar")'
)
;
=
.
createInstance
(
,
)
;
ctrl
.
apply
(
[
{
:
new
Range
(
1
,
5
,
1
,
10
)
,
:
'$1'
}
,
{
:
new
Range
(
1
,
1
,
1
,
1
)
,
:
'const ${1:new_const}$0 = "bar";\n'
}
]
)
;
.
strictEqual
(
.
getValue
(
)
,
'const new_const = "bar";\nfoo(new_const)'
)
;
assertContextKeys
(
,
true
,
false
,
true
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
7
,
1
,
16
)
,
new
Selection
(
2
,
5
,
2
,
14
)
]
)
;
.
next
(
)
;
assertContextKeys
(
,
false
,
false
,
false
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
16
,
1
,
16
)
]
)
;
}
)
;
test
(
'apply, tab, tab, done'
,
function
(
)
{
.
setValue
(
'foo\nbar'
)
;
=
.
createInstance
(
,
)
;
ctrl
.
apply
(
[
{
:
new
Range
(
1
,
4
,
1
,
4
)
,
:
'${3}'
}
,
{
:
new
Range
(
2
,
4
,
2
,
4
)
,
:
'$3'
}
,
{
:
new
Range
(
1
,
1
,
1
,
1
)
,
:
'### ${2:Header}\n'
}
]
)
;
.
strictEqual
(
.
getValue
(
)
,
'### Header\nfoo\nbar'
)
;
.
deepStrictEqual
(
getContextState
(
)
,
{
:
true
,
:
false
,
:
true
}
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
5
,
1
,
11
)
]
)
;
.
next
(
)
;
.
deepStrictEqual
(
getContextState
(
)
,
{
:
true
,
:
true
,
:
true
}
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
2
,
4
,
2
,
4
)
,
new
Selection
(
3
,
4
,
3
,
4
)
]
)
;
.
next
(
)
;
.
deepStrictEqual
(
getContextState
(
)
,
{
:
false
,
:
false
,
:
false
}
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
3
,
4
,
3
,
4
)
]
)
;
}
)
;
test
(
'nested into apply works'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
'onetwo'
)
;
.
setSelections
(
[
new
Selection
(
1
,
1
,
1
,
1
)
,
new
Selection
(
2
,
1
,
2
,
1
)
]
)
;
ctrl
.
apply
(
[
{
:
new
Range
(
1
,
7
,
1
,
7
)
,
:
'$0${1:three}'
}
]
)
;
.
strictEqual
(
.
getValue
(
)
,
'onetwothree'
)
;
.
deepStrictEqual
(
getContextState
(
)
,
{
:
true
,
:
false
,
:
true
}
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
7
,
1
,
12
)
]
)
;
.
insert
(
'foo$1bar$1'
)
;
.
strictEqual
(
.
getValue
(
)
,
'onetwofoobar'
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
10
,
1
,
10
)
,
new
Selection
(
1
,
13
,
1
,
13
)
]
)
;
.
deepStrictEqual
(
getContextState
(
)
,
(
{
:
true
,
:
false
,
:
true
}
)
)
;
.
next
(
)
;
.
deepStrictEqual
(
getContextState
(
)
,
(
{
:
true
,
:
true
,
:
true
}
)
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
13
,
1
,
13
)
]
)
;
.
next
(
)
;
.
deepStrictEqual
(
getContextState
(
)
,
{
:
false
,
:
false
,
:
false
}
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
7
,
1
,
7
)
]
)
;
}
)
;
test
(
'nested into insert abort "outer" snippet'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
'one\ntwo'
)
;
.
setSelections
(
[
new
Selection
(
1
,
1
,
1
,
1
)
,
new
Selection
(
2
,
1
,
2
,
1
)
]
)
;
.
insert
(
'foo${1:bar}bazz${1:bang}'
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
4
,
1
,
7
)
,
new
Selection
(
1
,
11
,
1
,
14
)
,
new
Selection
(
2
,
4
,
2
,
7
)
,
new
Selection
(
2
,
11
,
2
,
14
)
]
)
;
.
deepStrictEqual
(
getContextState
(
)
,
{
:
true
,
:
false
,
:
true
}
)
;
ctrl
.
apply
(
[
{
:
new
Range
(
1
,
4
,
1
,
7
)
,
:
'$0A'
}
]
)
;
.
strictEqual
(
.
getValue
(
)
,
'fooAbazzbarone\nfoobarbazzbartwo'
)
;
.
deepStrictEqual
(
getContextState
(
)
,
{
:
false
,
:
false
,
:
false
}
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
4
,
1
,
4
)
]
)
;
}
)
;
test
(
'nested into "insert" abort "outer" snippet (2)'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
'one\ntwo'
)
;
.
setSelections
(
[
new
Selection
(
1
,
1
,
1
,
1
)
,
new
Selection
(
2
,
1
,
2
,
1
)
]
)
;
.
insert
(
'foo${1:bar}bazz${1:bang}'
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
4
,
1
,
7
)
,
new
Selection
(
1
,
11
,
1
,
14
)
,
new
Selection
(
2
,
4
,
2
,
7
)
,
new
Selection
(
2
,
11
,
2
,
14
)
]
)
;
.
deepStrictEqual
(
getContextState
(
)
,
{
:
true
,
:
false
,
:
true
}
)
;
const
=
[
{
:
new
Range
(
1
,
4
,
1
,
7
)
,
:
'A'
}
,
{
:
new
Range
(
1
,
11
,
1
,
14
)
,
:
'B'
}
,
{
:
new
Range
(
2
,
4
,
2
,
7
)
,
:
'C'
}
,
{
:
new
Range
(
2
,
11
,
2
,
14
)
,
:
'D'
}
]
;
ctrl
.
apply
(
)
;
.
strictEqual
(
.
getValue
(
)
,
'fooAbazzBone\nfooCbazzDtwo'
)
;
.
deepStrictEqual
(
getContextState
(
)
,
{
:
false
,
:
false
,
:
false
}
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
5
,
1
,
5
)
,
new
Selection
(
1
,
10
,
1
,
10
)
,
new
Selection
(
2
,
5
,
2
,
5
)
,
new
Selection
(
2
,
10
,
2
,
10
)
]
)
;
}
)
;
}
)
;
test
(
'Bug: cursor position $0 with user snippets #163808'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
insert
(
'<Element1 Attr1="foo" $1>\n <Element2 Attr1="$2"/>\n$0"\n</Element1>'
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
23
,
1
,
23
)
]
)
;
.
insert
(
'Qualifier="$0"'
)
;
.
strictEqual
(
.
getValue
(
)
,
'<Element1 Attr1="foo" Qualifier="">\n <Element2 Attr1=""/>\n"\n</Element1>'
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
34
,
1
,
34
)
]
)
;
}
)
;
test
(
'EOL-Sequence (CRLF) shifts tab stop in isFileTemplate snippets #167386'
,
function
(
)
{
=
.
createInstance
(
,
)
;
.
setValue
(
''
)
;
.
setEOL
(
.
CRLF
)
;
ctrl
.
apply
(
[
{
:
.
getFullModelRange
(
)
,
:
'line 54321${1:FOO}\nline 54321${1:FOO}\n(no tab stop)\nline 54321${1:FOO}\nline 54321'
}
]
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
11
,
1
,
14
)
,
new
Selection
(
2
,
11
,
2
,
14
)
,
new
Selection
(
4
,
11
,
4
,
14
)
]
)
;
}
)
;
test
(
'"Surround With" code action snippets use incorrect indentation levels and styles #169319'
,
function
(
)
{
.
setValue
(
'function foo(f, x, condition) {\n f();\n return x;\n}'
)
;
const
=
new
Range
(
2
,
5
,
3
,
14
)
;
.
setSelection
(
)
;
=
.
createInstance
(
,
)
;
ctrl
.
apply
(
[
{
:
,
:
'if (${1:condition}) {\n\t$TM_SELECTED_TEXT$0\n}'
}
]
)
;
.
strictEqual
(
.
getValue
(
)
,
` function foo(f, x, condition) {\n if (condition) {\n f();\n return x;\n }\n} `
)
;
}
)
;
test
(
'$TM_SELECTED_TEXT resolves per edit, not the last selection (multi-cursor wrap snippet) #206121'
,
function
(
)
{
.
setValue
(
'aaa\nbbb\nccc'
)
;
const
=
[
new
Range
(
1
,
1
,
1
,
4
)
,
new
Range
(
2
,
1
,
2
,
4
)
,
new
Range
(
3
,
1
,
3
,
4
)
]
;
.
setSelections
(
.
map
(
=>
new
Selection
(
.
,
.
,
.
,
.
)
)
)
;
=
.
createInstance
(
,
)
;
ctrl
.
apply
(
.
map
(
=>
(
{
,
:
'if(${1:cond}) {$TM_SELECTED_TEXT}$0'
}
)
)
)
;
.
strictEqual
(
.
getValue
(
)
,
'if(cond) {aaa}\nif(cond) {bbb}\nif(cond) {ccc}'
)
;
}
)
;
test
(
'apply with multiple cursors threads $CURSOR_NUMBER per edit'
,
function
(
)
{
.
setValue
(
'aa\nbb\ncc'
)
;
=
.
createInstance
(
,
)
;
ctrl
.
apply
(
[
{
:
new
Range
(
1
,
3
,
1
,
3
)
,
:
':$CURSOR_NUMBER'
}
,
{
:
new
Range
(
2
,
3
,
2
,
3
)
,
:
':$CURSOR_NUMBER'
}
,
{
:
new
Range
(
3
,
3
,
3
,
3
)
,
:
':$CURSOR_NUMBER'
}
,
]
)
;
.
strictEqual
(
.
getValue
(
)
,
'aa:1\nbb:2\ncc:3'
)
;
}
)
;
test
(
'undo restores original selection after apply (regression for #170041)'
,
function
(
)
{
.
setValue
(
'Some text and more text'
)
;
.
setSelection
(
new
Selection
(
1
,
1
,
1
,
1
)
)
;
=
.
createInstance
(
,
)
;
ctrl
.
apply
(
[
{
:
new
Range
(
1
,
6
,
1
,
10
)
,
:
'${0:hi}'
}
]
)
;
.
strictEqual
(
.
getValue
(
)
,
'Some hi and more text'
)
;
.
runCommand
(
.
,
null
)
;
.
strictEqual
(
.
getValue
(
)
,
'Some text and more text'
)
;
.
deepStrictEqual
(
.
getSelections
(
)
,
[
new
Selection
(
1
,
1
,
1
,
1
)
]
)
;
}
)
;
}
)
;