ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / editor / test / common / model / model.test.ts 502 строк · изменён 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
import assert from 'assert' ;
import { Disposable, DisposableStore, dispose } from '../../../../base/common/lifecycle.js' ;
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js' ;
import { EditOperation } from '../../../common/core/editOperation.js' ;
import { Position } from '../../../common/core/position.js' ;
import { Range } from '../../../common/core/range.js' ;
import { MetadataConsts } from '../../../common/encodedTokenAttributes.js' ;
import { EncodedTokenizationResult, IState TokenizationRegistry
ILanguageService
ILanguageConfigurationService
NullState
TextModel
InternalModelContentChangeEvent ModelInjectedTextChangedEvent ModelRawContentChangedEvent ModelRawFlush ModelRawLineChanged ModelRawLinesDeleted ModelRawLinesInserted
createModelServices createTextModel instantiateTextModel
mock
IViewModel
thisModel TextModel
text
thisModel text
thisModel
assert thisModel
thisModel EditOperation
assert thisModel
assert thisModel
thisModel EditOperation
assert thisModel
assert thisModel
thisModel EditOperation
assert thisModel
assert thisModel
thisModel EditOperation
assert thisModel
assert thisModel
assert thisModel
thisModel EditOperation
assert thisModel
assert thisModel
assert thisModel
assert thisModel
thisModel EditOperation
assert thisModel
assert thisModel
assert thisModel
assert thisModel
assert thisModel
assert thisModel
ModelRawContentChangedEvent
e ModelRawContentChangedEvent
spyViewModel
override _e InternalModelContentChangeEvent ModelInjectedTextChangedEvent
e _e
assert
e _e rawContentChangedEvent
override e InternalModelContentChangeEvent ModelInjectedTextChangedEvent
thisModel spyViewModel
thisModel spyViewModel
e
e
thisModel EditOperation
assert e
e
thisModel EditOperation
assert e
e
thisModel EditOperation
assert e
thisModel EditOperation
assert thisModel
assert thisModel
thisModel EditOperation
assert thisModel
assert thisModel
thisModel EditOperation
assert thisModel
thisModel EditOperation
assert thisModel
assert thisModel
thisModel EditOperation
assert thisModel
assert thisModel
thisModel EditOperation
assert thisModel
assert thisModel
thisModel EditOperation
assert thisModel
assert thisModel
thisModel EditOperation
assert thisModel
assert thisModel
e
thisModel EditOperation
assert e
e
thisModel EditOperation
assert e
e
thisModel EditOperation
assert e
e
thisModel EditOperation
assert e
e
thisModel EditOperation
assert e
assert thisModel
assert thisModel
assert thisModel
assert thisModel
assert thisModel
assert thisModel
assert thisModel
assert thisModel
assert thisModel
assert thisModel
assert thisModel length
assert thisModel length
assert thisModel length
assert thisModel length
assert thisModel length
assert thisModel length
assert thisModel length
assert thisModel length
assert thisModel length
assert thisModel length
e
thisModel
assert e
res thisModel
range text
range text
assert res range
assert res range
thisModel TextModel
text
thisModel text
thisModel
assert thisModel
assert thisModel
model
assert model
assert model
model
languageId
languageService ILanguageService
languageConfigurationService ILanguageConfigurationService
languageService id languageId
languageConfigurationService languageId
languageIdCodec languageService languageIdCodec
TokenizationRegistry languageId
getInitialState IState NullState
tokenize
tokenizeEncoded line hasEOL state IState EncodedTokenizationResult
tokensArr
prevLanguageId
i i line length i
languageId line i
encodedLanguageId languageIdCodec languageId
prevLanguageId languageId
tokensArr i
tokensArr encodedLanguageId MetadataConsts
prevLanguageId languageId
tokens tokensArr length
i i tokens length i
tokens i tokensArr i
tokens state
languageId
languageService ILanguageService
languageConfigurationService ILanguageConfigurationService
languageService id languageId
languageConfigurationService languageId
disposables Disposable
disposables
disposables
disposables
text
thisModel text
disposables thisModel
assert thisModel word startColumn endColumn
assert thisModel word startColumn endColumn
assert thisModel word startColumn endColumn
assert thisModel word startColumn endColumn
assert thisModel word startColumn endColumn
assert thisModel word startColumn endColumn
assert thisModel
assert thisModel word startColumn endColumn
assert thisModel word startColumn endColumn
assert thisModel
assert thisModel
disposables
instantiationService disposables
outerMode disposables instantiationService OuterMode
disposables instantiationService InnerMode
model disposables instantiationService outerMode languageId
assert model word startColumn endColumn
assert model word startColumn endColumn
assert model word startColumn endColumn
assert model word startColumn endColumn
assert model word startColumn endColumn
assert model word startColumn endColumn
assert model word startColumn endColumn
disposables
disposables
instantiationService disposables
languageConfigurationService instantiationService ILanguageConfigurationService
languageService instantiationService ILanguageService
disposables languageService id
disposables languageConfigurationService
wordPattern
thisModel disposables instantiationService
assert thisModel word startColumn endColumn
assert thisModel word startColumn endColumn
assert thisModel
assert thisModel word startColumn endColumn
assert thisModel word startColumn endColumn
assert thisModel word startColumn endColumn
assert thisModel word startColumn endColumn
assert thisModel word startColumn endColumn
disposables
,
}
from
'../../../common/languages.js'
;
import
{
}
from
'../../../common/languages/language.js'
;
import
{
}
from
'../../../common/languages/languageConfigurationRegistry.js'
;
import
{
}
from
'../../../common/languages/nullTokenize.js'
;
import
{
}
from
'../../../common/model/textModel.js'
;
import
{
,
,
,
,
,
,
}
from
'../../../common/textModelEvents.js'
;
import
{
,
,
}
from
'../testTextModel.js'
;
import
{
}
from
'../../../../base/test/common/mock.js'
;
import
{
}
from
'../../../common/viewModel.js'
;
const
LINE1
=
'My First Line'
;
const
LINE2
=
'\t\tMy Second Line'
;
const
LINE3
=
' Third Line'
;
const
LINE4
=
''
;
const
LINE5
=
'1'
;
suite
(
'Editor Model - Model'
,
(
)
=>
{
let
:
;
setup
(
(
)
=>
{
const
=
LINE1
+
'\r\n'
+
LINE2
+
'\n'
+
LINE3
+
'\n'
+
LINE4
+
'\r\n'
+
LINE5
;
=
createTextModel
(
)
;
}
)
;
teardown
(
(
)
=>
{
.
dispose
(
)
;
}
)
;
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
test
(
'model getValue'
,
(
)
=>
{
.
strictEqual
(
.
getValue
(
)
,
'My First Line\n\t\tMy Second Line\n Third Line\n\n1'
)
;
}
)
;
test
(
'model insert empty text'
,
(
)
=>
{
.
applyEdits
(
[
.
insert
(
new
Position
(
1
,
1
)
,
''
)
]
)
;
.
strictEqual
(
.
getLineCount
(
)
,
5
)
;
.
strictEqual
(
.
getLineContent
(
1
)
,
'My First Line'
)
;
}
)
;
test
(
'model insert text without newline 1'
,
(
)
=>
{
.
applyEdits
(
[
.
insert
(
new
Position
(
1
,
1
)
,
'foo '
)
]
)
;
.
strictEqual
(
.
getLineCount
(
)
,
5
)
;
.
strictEqual
(
.
getLineContent
(
1
)
,
'foo My First Line'
)
;
}
)
;
test
(
'model insert text without newline 2'
,
(
)
=>
{
.
applyEdits
(
[
.
insert
(
new
Position
(
1
,
3
)
,
' foo'
)
]
)
;
.
strictEqual
(
.
getLineCount
(
)
,
5
)
;
.
strictEqual
(
.
getLineContent
(
1
)
,
'My foo First Line'
)
;
}
)
;
test
(
'model insert text with one newline'
,
(
)
=>
{
.
applyEdits
(
[
.
insert
(
new
Position
(
1
,
3
)
,
' new line\nNo longer'
)
]
)
;
.
strictEqual
(
.
getLineCount
(
)
,
6
)
;
.
strictEqual
(
.
getLineContent
(
1
)
,
'My new line'
)
;
.
strictEqual
(
.
getLineContent
(
2
)
,
'No longer First Line'
)
;
}
)
;
test
(
'model insert text with two newlines'
,
(
)
=>
{
.
applyEdits
(
[
.
insert
(
new
Position
(
1
,
3
)
,
' new line\nOne more line in the middle\nNo longer'
)
]
)
;
.
strictEqual
(
.
getLineCount
(
)
,
7
)
;
.
strictEqual
(
.
getLineContent
(
1
)
,
'My new line'
)
;
.
strictEqual
(
.
getLineContent
(
2
)
,
'One more line in the middle'
)
;
.
strictEqual
(
.
getLineContent
(
3
)
,
'No longer First Line'
)
;
}
)
;
test
(
'model insert text with many newlines'
,
(
)
=>
{
.
applyEdits
(
[
.
insert
(
new
Position
(
1
,
3
)
,
'\n\n\n\n'
)
]
)
;
.
strictEqual
(
.
getLineCount
(
)
,
9
)
;
.
strictEqual
(
.
getLineContent
(
1
)
,
'My'
)
;
.
strictEqual
(
.
getLineContent
(
2
)
,
''
)
;
.
strictEqual
(
.
getLineContent
(
3
)
,
''
)
;
.
strictEqual
(
.
getLineContent
(
4
)
,
''
)
;
.
strictEqual
(
.
getLineContent
(
5
)
,
' First Line'
)
;
}
)
;
function
withEventCapturing
(
callback
:
(
)
=>
void
)
:
|
null
{
let
:
|
null
=
null
;
const
=
new
class
extends
mock< IViewModel>
(
)
{
onDidChangeContentOrInjectedText
(
:
|
)
{
if
(
!==
null
||
!
(
instanceof
InternalModelContentChangeEvent
)
)
{
.
fail
(
'Unexpected assertion error'
)
;
}
=
.
;
}
emitContentChangeEvent
(
:
|
)
:
void
{
}
}
;
.
registerViewModel
(
)
;
callback
(
)
;
.
unregisterViewModel
(
)
;
return
;
}
test
(
'model insert empty text does not trigger eventing'
,
(
)
=>
{
const
=
withEventCapturing
(
(
)
=>
{
.
applyEdits
(
[
.
insert
(
new
Position
(
1
,
1
)
,
''
)
]
)
;
}
)
;
.
deepStrictEqual
(
,
null
,
'was not expecting event'
)
;
}
)
;
test
(
'model insert text without newline eventing'
,
(
)
=>
{
const
=
withEventCapturing
(
(
)
=>
{
.
applyEdits
(
[
.
insert
(
new
Position
(
1
,
1
)
,
'foo '
)
]
)
;
}
)
;
.
deepStrictEqual
(
,
new
ModelRawContentChangedEvent
(
[
new
ModelRawLineChanged
(
1
,
1
)
]
,
2
,
false
,
false
)
)
;
}
)
;
test
(
'model insert text with one newline eventing'
,
(
)
=>
{
const
=
withEventCapturing
(
(
)
=>
{
.
applyEdits
(
[
.
insert
(
new
Position
(
1
,
3
)
,
' new line\nNo longer'
)
]
)
;
}
)
;
.
deepStrictEqual
(
,
new
ModelRawContentChangedEvent
(
[
new
ModelRawLineChanged
(
1
,
1
)
,
new
ModelRawLinesInserted
(
2
,
2
,
1
)
,
]
,
2
,
false
,
false
)
)
;
}
)
;
test
(
'model delete empty text'
,
(
)
=>
{
.
applyEdits
(
[
.
delete
(
new
Range
(
1
,
1
,
1
,
1
)
)
]
)
;
.
strictEqual
(
.
getLineCount
(
)
,
5
)
;
.
strictEqual
(
.
getLineContent
(
1
)
,
'My First Line'
)
;
}
)
;
test
(
'model delete text from one line'
,
(
)
=>
{
.
applyEdits
(
[
.
delete
(
new
Range
(
1
,
1
,
1
,
2
)
)
]
)
;
.
strictEqual
(
.
getLineCount
(
)
,
5
)
;
.
strictEqual
(
.
getLineContent
(
1
)
,
'y First Line'
)
;
}
)
;
test
(
'model delete text from one line 2'
,
(
)
=>
{
.
applyEdits
(
[
.
insert
(
new
Position
(
1
,
1
)
,
'a'
)
]
)
;
.
strictEqual
(
.
getLineContent
(
1
)
,
'aMy First Line'
)
;
.
applyEdits
(
[
.
delete
(
new
Range
(
1
,
2
,
1
,
4
)
)
]
)
;
.
strictEqual
(
.
getLineCount
(
)
,
5
)
;
.
strictEqual
(
.
getLineContent
(
1
)
,
'a First Line'
)
;
}
)
;
test
(
'model delete all text from a line'
,
(
)
=>
{
.
applyEdits
(
[
.
delete
(
new
Range
(
1
,
1
,
1
,
14
)
)
]
)
;
.
strictEqual
(
.
getLineCount
(
)
,
5
)
;
.
strictEqual
(
.
getLineContent
(
1
)
,
''
)
;
}
)
;
test
(
'model delete text from two lines'
,
(
)
=>
{
.
applyEdits
(
[
.
delete
(
new
Range
(
1
,
4
,
2
,
6
)
)
]
)
;
.
strictEqual
(
.
getLineCount
(
)
,
4
)
;
.
strictEqual
(
.
getLineContent
(
1
)
,
'My Second Line'
)
;
}
)
;
test
(
'model delete text from many lines'
,
(
)
=>
{
.
applyEdits
(
[
.
delete
(
new
Range
(
1
,
4
,
3
,
5
)
)
]
)
;
.
strictEqual
(
.
getLineCount
(
)
,
3
)
;
.
strictEqual
(
.
getLineContent
(
1
)
,
'My Third Line'
)
;
}
)
;
test
(
'model delete everything'
,
(
)
=>
{
.
applyEdits
(
[
.
delete
(
new
Range
(
1
,
1
,
5
,
2
)
)
]
)
;
.
strictEqual
(
.
getLineCount
(
)
,
1
)
;
.
strictEqual
(
.
getLineContent
(
1
)
,
''
)
;
}
)
;
test
(
'model delete empty text does not trigger eventing'
,
(
)
=>
{
const
=
withEventCapturing
(
(
)
=>
{
.
applyEdits
(
[
.
delete
(
new
Range
(
1
,
1
,
1
,
1
)
)
]
)
;
}
)
;
.
deepStrictEqual
(
,
null
,
'was not expecting event'
)
;
}
)
;
test
(
'model delete text from one line eventing'
,
(
)
=>
{
const
=
withEventCapturing
(
(
)
=>
{
.
applyEdits
(
[
.
delete
(
new
Range
(
1
,
1
,
1
,
2
)
)
]
)
;
}
)
;
.
deepStrictEqual
(
,
new
ModelRawContentChangedEvent
(
[
new
ModelRawLineChanged
(
1
,
1
)
,
]
,
2
,
false
,
false
)
)
;
}
)
;
test
(
'model delete all text from a line eventing'
,
(
)
=>
{
const
=
withEventCapturing
(
(
)
=>
{
.
applyEdits
(
[
.
delete
(
new
Range
(
1
,
1
,
1
,
14
)
)
]
)
;
}
)
;
.
deepStrictEqual
(
,
new
ModelRawContentChangedEvent
(
[
new
ModelRawLineChanged
(
1
,
1
)
,
]
,
2
,
false
,
false
)
)
;
}
)
;
test
(
'model delete text from two lines eventing'
,
(
)
=>
{
const
=
withEventCapturing
(
(
)
=>
{
.
applyEdits
(
[
.
delete
(
new
Range
(
1
,
4
,
2
,
6
)
)
]
)
;
}
)
;
.
deepStrictEqual
(
,
new
ModelRawContentChangedEvent
(
[
new
ModelRawLineChanged
(
1
,
1
)
,
new
ModelRawLinesDeleted
(
2
,
2
,
1
)
,
]
,
2
,
false
,
false
)
)
;
}
)
;
test
(
'model delete text from many lines eventing'
,
(
)
=>
{
const
=
withEventCapturing
(
(
)
=>
{
.
applyEdits
(
[
.
delete
(
new
Range
(
1
,
4
,
3
,
5
)
)
]
)
;
}
)
;
.
deepStrictEqual
(
,
new
ModelRawContentChangedEvent
(
[
new
ModelRawLineChanged
(
1
,
1
)
,
new
ModelRawLinesDeleted
(
2
,
3
,
1
)
,
]
,
2
,
false
,
false
)
)
;
}
)
;
test
(
'getValueInRange'
,
(
)
=>
{
.
strictEqual
(
.
getValueInRange
(
new
Range
(
1
,
1
,
1
,
1
)
)
,
''
)
;
.
strictEqual
(
.
getValueInRange
(
new
Range
(
1
,
1
,
1
,
2
)
)
,
'M'
)
;
.
strictEqual
(
.
getValueInRange
(
new
Range
(
1
,
2
,
1
,
3
)
)
,
'y'
)
;
.
strictEqual
(
.
getValueInRange
(
new
Range
(
1
,
1
,
1
,
14
)
)
,
'My First Line'
)
;
.
strictEqual
(
.
getValueInRange
(
new
Range
(
1
,
1
,
2
,
1
)
)
,
'My First Line\n'
)
;
.
strictEqual
(
.
getValueInRange
(
new
Range
(
1
,
1
,
2
,
2
)
)
,
'My First Line\n\t'
)
;
.
strictEqual
(
.
getValueInRange
(
new
Range
(
1
,
1
,
2
,
3
)
)
,
'My First Line\n\t\t'
)
;
.
strictEqual
(
.
getValueInRange
(
new
Range
(
1
,
1
,
2
,
17
)
)
,
'My First Line\n\t\tMy Second Line'
)
;
.
strictEqual
(
.
getValueInRange
(
new
Range
(
1
,
1
,
3
,
1
)
)
,
'My First Line\n\t\tMy Second Line\n'
)
;
.
strictEqual
(
.
getValueInRange
(
new
Range
(
1
,
1
,
4
,
1
)
)
,
'My First Line\n\t\tMy Second Line\n Third Line\n'
)
;
}
)
;
test
(
'getValueLengthInRange'
,
(
)
=>
{
.
strictEqual
(
.
getValueLengthInRange
(
new
Range
(
1
,
1
,
1
,
1
)
)
,
''
.
)
;
.
strictEqual
(
.
getValueLengthInRange
(
new
Range
(
1
,
1
,
1
,
2
)
)
,
'M'
.
)
;
.
strictEqual
(
.
getValueLengthInRange
(
new
Range
(
1
,
2
,
1
,
3
)
)
,
'y'
.
)
;
.
strictEqual
(
.
getValueLengthInRange
(
new
Range
(
1
,
1
,
1
,
14
)
)
,
'My First Line'
.
)
;
.
strictEqual
(
.
getValueLengthInRange
(
new
Range
(
1
,
1
,
2
,
1
)
)
,
'My First Line\n'
.
)
;
.
strictEqual
(
.
getValueLengthInRange
(
new
Range
(
1
,
1
,
2
,
2
)
)
,
'My First Line\n\t'
.
)
;
.
strictEqual
(
.
getValueLengthInRange
(
new
Range
(
1
,
1
,
2
,
3
)
)
,
'My First Line\n\t\t'
.
)
;
.
strictEqual
(
.
getValueLengthInRange
(
new
Range
(
1
,
1
,
2
,
17
)
)
,
'My First Line\n\t\tMy Second Line'
.
)
;
.
strictEqual
(
.
getValueLengthInRange
(
new
Range
(
1
,
1
,
3
,
1
)
)
,
'My First Line\n\t\tMy Second Line\n'
.
)
;
.
strictEqual
(
.
getValueLengthInRange
(
new
Range
(
1
,
1
,
4
,
1
)
)
,
'My First Line\n\t\tMy Second Line\n Third Line\n'
.
)
;
}
)
;
test
(
'setValue eventing'
,
(
)
=>
{
const
=
withEventCapturing
(
(
)
=>
{
.
setValue
(
'new value'
)
;
}
)
;
.
deepStrictEqual
(
,
new
ModelRawContentChangedEvent
(
[
new
ModelRawFlush
(
)
]
,
2
,
false
,
false
)
)
;
}
)
;
test
(
'issue #46342: Maintain edit operation order in applyEdits'
,
(
)
=>
{
const
=
.
applyEdits
(
[
{
:
new
Range
(
2
,
1
,
2
,
1
)
,
:
'a'
}
,
{
:
new
Range
(
1
,
1
,
1
,
1
)
,
:
'b'
}
,
]
,
true
)
;
.
deepStrictEqual
(
[
0
]
.
,
new
Range
(
2
,
1
,
2
,
2
)
)
;
.
deepStrictEqual
(
[
1
]
.
,
new
Range
(
1
,
1
,
1
,
2
)
)
;
}
)
;
}
)
;
suite
(
'Editor Model - Model Line Separators'
,
(
)
=>
{
let
:
;
setup
(
(
)
=>
{
const
=
LINE1
+
'\u2028'
+
LINE2
+
'\n'
+
LINE3
+
'\u2028'
+
LINE4
+
'\r\n'
+
LINE5
;
=
createTextModel
(
)
;
}
)
;
teardown
(
(
)
=>
{
.
dispose
(
)
;
}
)
;
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
test
(
'model getValue'
,
(
)
=>
{
.
strictEqual
(
.
getValue
(
)
,
'My First Line\u2028\t\tMy Second Line\n Third Line\u2028\n1'
)
;
}
)
;
test
(
'model lines'
,
(
)
=>
{
.
strictEqual
(
.
getLineCount
(
)
,
3
)
;
}
)
;
test
(
'Bug 13333:Model should line break on lonely CR too'
,
(
)
=>
{
const
=
createTextModel
(
'Hello\rWorld!\r\nAnother line'
)
;
.
strictEqual
(
.
getLineCount
(
)
,
3
)
;
.
strictEqual
(
.
getValue
(
)
,
'Hello\r\nWorld!\r\nAnother line'
)
;
.
dispose
(
)
;
}
)
;
}
)
;
suite
(
'Editor Model - Words'
,
(
)
=>
{
const
OUTER_LANGUAGE_ID
=
'outerMode'
;
const
INNER_LANGUAGE_ID
=
'innerMode'
;
class
OuterMode
extends
Disposable
{
public
readonly
=
OUTER_LANGUAGE_ID
;
constructor
(
@ ILanguageService
:
,
@ ILanguageConfigurationService
:
)
{
super
(
)
;
this
.
_register
(
.
registerLanguage
(
{
:
this
.
}
)
)
;
this
.
_register
(
.
register
(
this
.
,
{
}
)
)
;
const
=
.
;
this
.
_register
(
.
register
(
this
.
,
{
:
(
)
:
=>
,
:
undefined
!
,
:
(
:
string
,
:
boolean
,
:
)
:
=>
{
const
:
number
[
]
=
[
]
;
let
:
string
|
undefined
=
undefined
;
for
(
let
=
0
;
<
.
;
++
)
{
const
=
(
.
charAt
(
)
===
'x'
?
INNER_LANGUAGE_ID
:
OUTER_LANGUAGE_ID
)
;
const
=
.
encodeLanguageId
(
)
;
if
(
!==
)
{
.
push
(
)
;
.
push
(
(
<<
.
LANGUAGEID_OFFSET
)
)
;
}
=
;
}
const
=
new
Uint32Array
(
.
)
;
for
(
let
=
0
;
<
.
;
++
)
{
[
]
=
[
]
;
}
return
new
EncodedTokenizationResult
(
,
[
]
,
)
;
}
}
)
)
;
}
}
class
InnerMode
extends
Disposable
{
public
readonly
=
INNER_LANGUAGE_ID
;
constructor
(
@ ILanguageService
:
,
@ ILanguageConfigurationService
:
)
{
super
(
)
;
this
.
_register
(
.
registerLanguage
(
{
:
this
.
}
)
)
;
this
.
_register
(
.
register
(
this
.
,
{
}
)
)
;
}
}
let
:
[
]
=
[
]
;
setup
(
(
)
=>
{
=
[
]
;
}
)
;
teardown
(
(
)
=>
{
dispose
(
)
;
=
[
]
;
}
)
;
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
test
(
'Get word at position'
,
(
)
=>
{
const
=
[
'This text has some words. '
]
;
const
=
createTextModel
(
.
join
(
'\n'
)
)
;
.
push
(
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
1
)
)
,
{
:
'This'
,
:
1
,
:
5
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
2
)
)
,
{
:
'This'
,
:
1
,
:
5
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
4
)
)
,
{
:
'This'
,
:
1
,
:
5
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
5
)
)
,
{
:
'This'
,
:
1
,
:
5
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
6
)
)
,
{
:
'text'
,
:
6
,
:
10
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
19
)
)
,
{
:
'some'
,
:
15
,
:
19
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
20
)
)
,
null
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
21
)
)
,
{
:
'words'
,
:
21
,
:
26
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
26
)
)
,
{
:
'words'
,
:
21
,
:
26
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
27
)
)
,
null
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
28
)
)
,
null
)
;
}
)
;
test
(
'getWordAtPosition at embedded language boundaries'
,
(
)
=>
{
const
=
new
DisposableStore
(
)
;
const
=
createModelServices
(
)
;
const
=
.
add
(
.
createInstance
(
)
)
;
.
add
(
.
createInstance
(
)
)
;
const
=
.
add
(
instantiateTextModel
(
,
'ab<xx>ab<x>'
,
.
)
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
1
)
)
,
{
:
'ab'
,
:
1
,
:
3
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
2
)
)
,
{
:
'ab'
,
:
1
,
:
3
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
3
)
)
,
{
:
'ab'
,
:
1
,
:
3
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
4
)
)
,
{
:
'xx'
,
:
4
,
:
6
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
5
)
)
,
{
:
'xx'
,
:
4
,
:
6
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
6
)
)
,
{
:
'xx'
,
:
4
,
:
6
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
7
)
)
,
{
:
'ab'
,
:
7
,
:
9
}
)
;
.
dispose
(
)
;
}
)
;
test
(
'issue #61296: VS code freezes when editing CSS file with emoji'
,
(
)
=>
{
const
MODE_ID
=
'testMode'
;
const
=
new
DisposableStore
(
)
;
const
=
createModelServices
(
)
;
const
=
.
get
(
)
;
const
=
.
get
(
)
;
.
add
(
.
registerLanguage
(
{
:
MODE_ID
}
)
)
;
.
add
(
.
register
(
MODE_ID
,
{
:
/ ( #? -? \d * \. \d \w * %? ) | ( ::? [ \w -] * (?= [ ^ ,{;] * [ ,{] ) ) | ( ( [ @#.!] ) ? [ \w - ?] + %? | [ @#!.] ) / g
}
)
)
;
const
=
.
add
(
instantiateTextModel
(
,
'.🐷-a-b'
,
MODE_ID
)
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
1
)
)
,
{
:
'.'
,
:
1
,
:
2
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
2
)
)
,
{
:
'.'
,
:
1
,
:
2
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
3
)
)
,
null
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
4
)
)
,
{
:
'-a-b'
,
:
4
,
:
8
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
5
)
)
,
{
:
'-a-b'
,
:
4
,
:
8
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
6
)
)
,
{
:
'-a-b'
,
:
4
,
:
8
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
7
)
)
,
{
:
'-a-b'
,
:
4
,
:
8
}
)
;
.
deepStrictEqual
(
.
getWordAtPosition
(
new
Position
(
1
,
8
)
)
,
{
:
'-a-b'
,
:
4
,
:
8
}
)
;
.
dispose
(
)
;
}
)
;
}
)
;