6
6
import * as assert from 'assert' ;
7
7
import { URI } from 'vs/base/common/uri' ;
8
8
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
9
- import { TextFileEditorModelManager } from 'vs/workbench/services/textfile/common/textFileEditorModelManager' ;
10
9
import { workbenchInstantiationService , TestServiceAccessor , TestTextFileEditorModelManager } from 'vs/workbench/test/browser/workbenchTestServices' ;
11
10
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel' ;
12
11
import { FileChangesEvent , FileChangeType , FileOperationError , FileOperationResult } from 'vs/platform/files/common/files' ;
@@ -34,7 +33,7 @@ suite('Files - TextFileEditorModelManager', () => {
34
33
} ) ;
35
34
36
35
test ( 'add, remove, clear, get, getAll' , function ( ) {
37
- const manager : TestTextFileEditorModelManager = instantiationService . createInstance ( TestTextFileEditorModelManager ) ;
36
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
38
37
39
38
const model1 : TextFileEditorModel = instantiationService . createInstance ( TextFileEditorModel , toResource . call ( this , '/path/random1.txt' ) , 'utf8' , undefined ) ;
40
39
const model2 : TextFileEditorModel = instantiationService . createInstance ( TextFileEditorModel , toResource . call ( this , '/path/random2.txt' ) , 'utf8' , undefined ) ;
@@ -91,7 +90,7 @@ suite('Files - TextFileEditorModelManager', () => {
91
90
} ) ;
92
91
93
92
test ( 'resolve' , async ( ) => {
94
- const manager : TestTextFileEditorModelManager = instantiationService . createInstance ( TestTextFileEditorModelManager ) ;
93
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
95
94
const resource = URI . file ( '/test.html' ) ;
96
95
const encoding = 'utf8' ;
97
96
@@ -131,7 +130,7 @@ suite('Files - TextFileEditorModelManager', () => {
131
130
} ) ;
132
131
133
132
test ( 'resolve (async)' , async ( ) => {
134
- const manager : TestTextFileEditorModelManager = instantiationService . createInstance ( TestTextFileEditorModelManager ) ;
133
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
135
134
const resource = URI . file ( '/path/index.txt' ) ;
136
135
137
136
await manager . resolve ( resource ) ;
@@ -154,7 +153,7 @@ suite('Files - TextFileEditorModelManager', () => {
154
153
} ) ;
155
154
156
155
test ( 'resolve (sync)' , async ( ) => {
157
- const manager : TestTextFileEditorModelManager = instantiationService . createInstance ( TestTextFileEditorModelManager ) ;
156
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
158
157
const resource = URI . file ( '/path/index.txt' ) ;
159
158
160
159
await manager . resolve ( resource ) ;
@@ -171,7 +170,7 @@ suite('Files - TextFileEditorModelManager', () => {
171
170
} ) ;
172
171
173
172
test ( 'resolve (sync) - model disposed when error and first call to resolve' , async ( ) => {
174
- const manager : TestTextFileEditorModelManager = instantiationService . createInstance ( TestTextFileEditorModelManager ) ;
173
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
175
174
const resource = URI . file ( '/path/index.txt' ) ;
176
175
177
176
accessor . textFileService . setReadStreamErrorOnce ( new FileOperationError ( 'fail' , FileOperationResult . FILE_OTHER_ERROR ) ) ;
@@ -188,7 +187,7 @@ suite('Files - TextFileEditorModelManager', () => {
188
187
} ) ;
189
188
190
189
test ( 'resolve (sync) - model not disposed when error and model existed before' , async ( ) => {
191
- const manager : TestTextFileEditorModelManager = instantiationService . createInstance ( TestTextFileEditorModelManager ) ;
190
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
192
191
const resource = URI . file ( '/path/index.txt' ) ;
193
192
194
193
await manager . resolve ( resource ) ;
@@ -207,7 +206,7 @@ suite('Files - TextFileEditorModelManager', () => {
207
206
} ) ;
208
207
209
208
test ( 'resolve with initial contents' , async ( ) => {
210
- const manager : TestTextFileEditorModelManager = instantiationService . createInstance ( TestTextFileEditorModelManager ) ;
209
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
211
210
const resource = URI . file ( '/test.html' ) ;
212
211
213
212
const model = await manager . resolve ( resource , { contents : createTextBufferFactory ( 'Hello World' ) } ) ;
@@ -223,7 +222,7 @@ suite('Files - TextFileEditorModelManager', () => {
223
222
} ) ;
224
223
225
224
test ( 'multiple resolves execute in sequence' , async ( ) => {
226
- const manager : TestTextFileEditorModelManager = instantiationService . createInstance ( TestTextFileEditorModelManager ) ;
225
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
227
226
const resource = URI . file ( '/test.html' ) ;
228
227
229
228
let resolvedModel : unknown ;
@@ -257,7 +256,7 @@ suite('Files - TextFileEditorModelManager', () => {
257
256
} ) ;
258
257
259
258
test ( 'removed from cache when model disposed' , function ( ) {
260
- const manager : TestTextFileEditorModelManager = instantiationService . createInstance ( TestTextFileEditorModelManager ) ;
259
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
261
260
262
261
const model1 : TextFileEditorModel = instantiationService . createInstance ( TextFileEditorModel , toResource . call ( this , '/path/random1.txt' ) , 'utf8' , undefined ) ;
263
262
const model2 : TextFileEditorModel = instantiationService . createInstance ( TextFileEditorModel , toResource . call ( this , '/path/random2.txt' ) , 'utf8' , undefined ) ;
@@ -279,7 +278,7 @@ suite('Files - TextFileEditorModelManager', () => {
279
278
} ) ;
280
279
281
280
test ( 'events' , async function ( ) {
282
- const manager : TextFileEditorModelManager = instantiationService . createInstance ( TextFileEditorModelManager ) ;
281
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
283
282
284
283
const resource1 = toResource . call ( this , '/path/index.txt' ) ;
285
284
const resource2 = toResource . call ( this , '/path/other.txt' ) ;
@@ -368,7 +367,7 @@ suite('Files - TextFileEditorModelManager', () => {
368
367
} ) ;
369
368
370
369
test ( 'disposing model takes it out of the manager' , async function ( ) {
371
- const manager : TextFileEditorModelManager = instantiationService . createInstance ( TextFileEditorModelManager ) ;
370
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
372
371
373
372
const resource = toResource . call ( this , '/path/index_something.txt' ) ;
374
373
@@ -380,7 +379,7 @@ suite('Files - TextFileEditorModelManager', () => {
380
379
} ) ;
381
380
382
381
test ( 'canDispose with dirty model' , async function ( ) {
383
- const manager : TextFileEditorModelManager = instantiationService . createInstance ( TextFileEditorModelManager ) ;
382
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
384
383
385
384
const resource = toResource . call ( this , '/path/index_something.txt' ) ;
386
385
@@ -414,7 +413,7 @@ suite('Files - TextFileEditorModelManager', () => {
414
413
id : languageId ,
415
414
} ) ;
416
415
417
- const manager : TextFileEditorModelManager = instantiationService . createInstance ( TextFileEditorModelManager ) ;
416
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
418
417
419
418
const resource = toResource . call ( this , '/path/index_something.txt' ) ;
420
419
@@ -429,7 +428,7 @@ suite('Files - TextFileEditorModelManager', () => {
429
428
} ) ;
430
429
431
430
test ( 'file change events trigger reload (on a resolved model)' , async ( ) => {
432
- const manager : TestTextFileEditorModelManager = instantiationService . createInstance ( TestTextFileEditorModelManager ) ;
431
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
433
432
const resource = URI . file ( '/path/index.txt' ) ;
434
433
435
434
await manager . resolve ( resource ) ;
@@ -451,7 +450,7 @@ suite('Files - TextFileEditorModelManager', () => {
451
450
} ) ;
452
451
453
452
test ( 'file change events trigger reload (after a model is resolved: https://github.com/microsoft/vscode/issues/132765)' , async ( ) => {
454
- const manager : TestTextFileEditorModelManager = instantiationService . createInstance ( TestTextFileEditorModelManager ) ;
453
+ const manager = accessor . textFileService . files as TestTextFileEditorModelManager ;
455
454
const resource = URI . file ( '/path/index.txt' ) ;
456
455
457
456
manager . resolve ( resource ) ;
0 commit comments