@codingame/monaco-vscode-files-service-override 25.1.2 → 26.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/vscode/src/vs/platform/files/browser/indexedDBFileSystemProvider.js +129 -80
- package/vscode/src/vs/platform/files/common/fileService.js +398 -218
- package/vscode/src/vs/platform/files/common/io.js +30 -20
- package/vscode/src/vs/workbench/services/files/browser/elevatedFileService.js +1 -1
- package/vscode/src/vs/workbench/services/textfile/browser/browserTextFileService.js +44 -23
- package/vscode/src/vs/workbench/services/textfile/browser/textFileService.js +176 -116
- package/vscode/src/vs/workbench/services/textfile/common/textFileEditorModelManager.js +95 -71
- package/vscode/src/vs/workbench/services/textfile/common/textFileSaveParticipant.js +6 -11
|
@@ -24,16 +24,22 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
24
24
|
get models() {
|
|
25
25
|
return [...( this.mapResourceToModel.values())];
|
|
26
26
|
}
|
|
27
|
-
constructor(
|
|
27
|
+
constructor(
|
|
28
|
+
instantiationService,
|
|
29
|
+
fileService,
|
|
30
|
+
notificationService,
|
|
31
|
+
workingCopyFileService,
|
|
32
|
+
uriIdentityService
|
|
33
|
+
) {
|
|
28
34
|
super();
|
|
29
35
|
this.instantiationService = instantiationService;
|
|
30
36
|
this.fileService = fileService;
|
|
31
37
|
this.notificationService = notificationService;
|
|
32
38
|
this.workingCopyFileService = workingCopyFileService;
|
|
33
39
|
this.uriIdentityService = uriIdentityService;
|
|
34
|
-
this._onDidCreate = this._register(( new Emitter(
|
|
35
|
-
|
|
36
|
-
)));
|
|
40
|
+
this._onDidCreate = this._register(( new Emitter({
|
|
41
|
+
leakWarningThreshold: 500
|
|
42
|
+
})));
|
|
37
43
|
this.onDidCreate = this._onDidCreate.event;
|
|
38
44
|
this._onDidResolve = this._register(( new Emitter()));
|
|
39
45
|
this.onDidResolve = this._onDidResolve.event;
|
|
@@ -63,7 +69,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
63
69
|
return {
|
|
64
70
|
onSaveError(error, model) {
|
|
65
71
|
notificationService.error(( localize(
|
|
66
|
-
|
|
72
|
+
14705,
|
|
67
73
|
"Failed to save '{0}': {1}",
|
|
68
74
|
model.name,
|
|
69
75
|
toErrorMessage(error, false)
|
|
@@ -77,11 +83,21 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
77
83
|
}
|
|
78
84
|
registerListeners() {
|
|
79
85
|
this._register(this.fileService.onDidFilesChange(e => this.onDidFilesChange(e)));
|
|
80
|
-
this._register(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this._register(
|
|
84
|
-
|
|
86
|
+
this._register(
|
|
87
|
+
this.fileService.onDidChangeFileSystemProviderCapabilities(e => this.onDidChangeFileSystemProviderCapabilities(e))
|
|
88
|
+
);
|
|
89
|
+
this._register(
|
|
90
|
+
this.fileService.onDidChangeFileSystemProviderRegistrations(e => this.onDidChangeFileSystemProviderRegistrations(e))
|
|
91
|
+
);
|
|
92
|
+
this._register(
|
|
93
|
+
this.workingCopyFileService.onWillRunWorkingCopyFileOperation(e => this.onWillRunWorkingCopyFileOperation(e))
|
|
94
|
+
);
|
|
95
|
+
this._register(
|
|
96
|
+
this.workingCopyFileService.onDidFailWorkingCopyFileOperation(e => this.onDidFailWorkingCopyFileOperation(e))
|
|
97
|
+
);
|
|
98
|
+
this._register(
|
|
99
|
+
this.workingCopyFileService.onDidRunWorkingCopyFileOperation(e => this.onDidRunWorkingCopyFileOperation(e))
|
|
100
|
+
);
|
|
85
101
|
}
|
|
86
102
|
onDidFilesChange(e) {
|
|
87
103
|
for (const model of this.models) {
|
|
@@ -118,8 +134,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
118
134
|
this.modelResolveQueue.queueFor(model.resource, async () => {
|
|
119
135
|
try {
|
|
120
136
|
await this.reload(model);
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
137
|
+
} catch (error) {
|
|
123
138
|
onUnexpectedError(error);
|
|
124
139
|
}
|
|
125
140
|
});
|
|
@@ -128,7 +143,10 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
128
143
|
onWillRunWorkingCopyFileOperation(e) {
|
|
129
144
|
if (e.operation === FileOperation.MOVE || e.operation === FileOperation.COPY) {
|
|
130
145
|
const modelsToRestore = [];
|
|
131
|
-
for (const {
|
|
146
|
+
for (const {
|
|
147
|
+
source,
|
|
148
|
+
target
|
|
149
|
+
} of e.files) {
|
|
132
150
|
if (source) {
|
|
133
151
|
if (this.uriIdentityService.extUri.isEqual(source, target)) {
|
|
134
152
|
continue;
|
|
@@ -154,7 +172,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
154
172
|
target: targetModelResource,
|
|
155
173
|
language: languageId ? {
|
|
156
174
|
id: languageId,
|
|
157
|
-
explicit: sourceModel.languageChangeSource ===
|
|
175
|
+
explicit: sourceModel.languageChangeSource === "user"
|
|
158
176
|
} : undefined,
|
|
159
177
|
encoding: sourceModel.getEncoding(),
|
|
160
178
|
snapshot: sourceModel.isDirty() ? sourceModel.createSnapshot() : undefined
|
|
@@ -180,41 +198,45 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
180
198
|
}
|
|
181
199
|
onDidRunWorkingCopyFileOperation(e) {
|
|
182
200
|
switch (e.operation) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
201
|
+
case FileOperation.CREATE:
|
|
202
|
+
e.waitUntil((async () => {
|
|
203
|
+
for (const {
|
|
204
|
+
target
|
|
205
|
+
} of e.files) {
|
|
206
|
+
const model = this.get(target);
|
|
207
|
+
if (model && !model.isDisposed()) {
|
|
208
|
+
await model.revert();
|
|
190
209
|
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
210
|
+
}
|
|
211
|
+
})());
|
|
212
|
+
break;
|
|
213
|
+
case FileOperation.MOVE:
|
|
214
|
+
case FileOperation.COPY:
|
|
215
|
+
e.waitUntil((async () => {
|
|
216
|
+
const modelsToRestore = this.mapCorrelationIdToModelsToRestore.get(e.correlationId);
|
|
217
|
+
if (modelsToRestore) {
|
|
218
|
+
this.mapCorrelationIdToModelsToRestore.delete(e.correlationId);
|
|
219
|
+
await Promises.settled(( modelsToRestore.map(async modelToRestore => {
|
|
220
|
+
const target = this.uriIdentityService.asCanonicalUri(modelToRestore.target);
|
|
221
|
+
const restoredModel = await this.resolve(target, {
|
|
222
|
+
reload: {
|
|
223
|
+
async: false
|
|
224
|
+
},
|
|
225
|
+
contents: modelToRestore.snapshot ? createTextBufferFactoryFromSnapshot(modelToRestore.snapshot) : undefined,
|
|
226
|
+
encoding: modelToRestore.encoding
|
|
227
|
+
});
|
|
228
|
+
if (modelToRestore.language?.id && modelToRestore.language.id !== PLAINTEXT_LANGUAGE_ID) {
|
|
229
|
+
if (modelToRestore.language.explicit) {
|
|
230
|
+
restoredModel.setLanguageId(modelToRestore.language.id);
|
|
213
231
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
232
|
+
else if (restoredModel.getLanguageId() === PLAINTEXT_LANGUAGE_ID && extname(target) !== PLAINTEXT_EXTENSION) {
|
|
233
|
+
restoredModel.updateTextEditorModel(undefined, modelToRestore.language.id);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
})));
|
|
237
|
+
}
|
|
238
|
+
})());
|
|
239
|
+
break;
|
|
218
240
|
}
|
|
219
241
|
}
|
|
220
242
|
get(resource) {
|
|
@@ -228,7 +250,11 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
228
250
|
if (model.isDirty() || model.isDisposed() || !( this.has(model.resource))) {
|
|
229
251
|
return;
|
|
230
252
|
}
|
|
231
|
-
await this.doResolve(model, {
|
|
253
|
+
await this.doResolve(model, {
|
|
254
|
+
reload: {
|
|
255
|
+
async: false
|
|
256
|
+
}
|
|
257
|
+
});
|
|
232
258
|
}
|
|
233
259
|
async resolve(resource, options) {
|
|
234
260
|
const pendingResolve = this.joinPendingResolves(resource);
|
|
@@ -243,8 +269,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
243
269
|
if (URI.isUri(resourceOrModel)) {
|
|
244
270
|
resource = resourceOrModel;
|
|
245
271
|
model = this.get(resource);
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
272
|
+
} else {
|
|
248
273
|
resource = resourceOrModel.resource;
|
|
249
274
|
model = resourceOrModel;
|
|
250
275
|
}
|
|
@@ -260,8 +285,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
260
285
|
(async () => {
|
|
261
286
|
try {
|
|
262
287
|
await model.resolve(options);
|
|
263
|
-
}
|
|
264
|
-
catch (error) {
|
|
288
|
+
} catch (error) {
|
|
265
289
|
if (!model.isDisposed()) {
|
|
266
290
|
onUnexpectedError(error);
|
|
267
291
|
}
|
|
@@ -278,7 +302,12 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
278
302
|
}
|
|
279
303
|
else {
|
|
280
304
|
didCreateModel = true;
|
|
281
|
-
const newModel = model = this.instantiationService.createInstance(
|
|
305
|
+
const newModel = model = this.instantiationService.createInstance(
|
|
306
|
+
TextFileEditorModel,
|
|
307
|
+
resource,
|
|
308
|
+
options ? options.encoding : undefined,
|
|
309
|
+
options ? options.languageId : undefined
|
|
310
|
+
);
|
|
282
311
|
modelResolve = model.resolve(options);
|
|
283
312
|
this.registerModel(newModel);
|
|
284
313
|
}
|
|
@@ -292,14 +321,12 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
292
321
|
}
|
|
293
322
|
try {
|
|
294
323
|
await modelResolve;
|
|
295
|
-
}
|
|
296
|
-
catch (error) {
|
|
324
|
+
} catch (error) {
|
|
297
325
|
if (didCreateModel) {
|
|
298
326
|
model.dispose();
|
|
299
327
|
}
|
|
300
328
|
throw error;
|
|
301
|
-
}
|
|
302
|
-
finally {
|
|
329
|
+
} finally {
|
|
303
330
|
this.mapResourceToPendingModelResolvers.delete(resource);
|
|
304
331
|
}
|
|
305
332
|
if (options?.languageId) {
|
|
@@ -327,19 +354,23 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
327
354
|
currentModelCopyResolve = nextPendingModelResolve;
|
|
328
355
|
try {
|
|
329
356
|
await nextPendingModelResolve;
|
|
330
|
-
}
|
|
331
|
-
catch (error) {
|
|
332
|
-
}
|
|
357
|
+
} catch (error) {}
|
|
333
358
|
}
|
|
334
359
|
}
|
|
335
360
|
registerModel(model) {
|
|
336
361
|
const modelListeners = ( new DisposableStore());
|
|
337
|
-
modelListeners.add(model.onDidResolve(reason => this._onDidResolve.fire({
|
|
362
|
+
modelListeners.add(model.onDidResolve(reason => this._onDidResolve.fire({
|
|
363
|
+
model,
|
|
364
|
+
reason
|
|
365
|
+
})));
|
|
338
366
|
modelListeners.add(model.onDidChangeDirty(() => this._onDidChangeDirty.fire(model)));
|
|
339
367
|
modelListeners.add(model.onDidChangeReadonly(() => this._onDidChangeReadonly.fire(model)));
|
|
340
368
|
modelListeners.add(model.onDidChangeOrphaned(() => this._onDidChangeOrphaned.fire(model)));
|
|
341
369
|
modelListeners.add(model.onDidSaveError(() => this._onDidSaveError.fire(model)));
|
|
342
|
-
modelListeners.add(model.onDidSave(e => this._onDidSave.fire({
|
|
370
|
+
modelListeners.add(model.onDidSave(e => this._onDidSave.fire({
|
|
371
|
+
model,
|
|
372
|
+
...e
|
|
373
|
+
})));
|
|
343
374
|
modelListeners.add(model.onDidRevert(() => this._onDidRevert.fire(model)));
|
|
344
375
|
modelListeners.add(model.onDidChangeEncoding(() => this._onDidChangeEncoding.fire(model)));
|
|
345
376
|
this.mapResourceToModelListeners.set(model.resource, modelListeners);
|
|
@@ -377,8 +408,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
377
408
|
return this.saveParticipants.participate(model, context, progress, token);
|
|
378
409
|
}
|
|
379
410
|
canDispose(model) {
|
|
380
|
-
if (model.isDisposed() ||
|
|
381
|
-
(!( this.mapResourceToPendingModelResolvers.has(model.resource)) && !model.isDirty())) {
|
|
411
|
+
if (model.isDisposed() || (!( this.mapResourceToPendingModelResolvers.has(model.resource)) && !model.isDirty())) {
|
|
382
412
|
return true;
|
|
383
413
|
}
|
|
384
414
|
return this.doCanDispose(model);
|
|
@@ -405,12 +435,6 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
405
435
|
this.mapResourceToModelListeners.clear();
|
|
406
436
|
}
|
|
407
437
|
};
|
|
408
|
-
TextFileEditorModelManager = ( __decorate([
|
|
409
|
-
( __param(0, IInstantiationService)),
|
|
410
|
-
( __param(1, IFileService)),
|
|
411
|
-
( __param(2, INotificationService)),
|
|
412
|
-
( __param(3, IWorkingCopyFileService)),
|
|
413
|
-
( __param(4, IUriIdentityService))
|
|
414
|
-
], TextFileEditorModelManager));
|
|
438
|
+
TextFileEditorModelManager = ( __decorate([( __param(0, IInstantiationService)), ( __param(1, IFileService)), ( __param(2, INotificationService)), ( __param(3, IWorkingCopyFileService)), ( __param(4, IUriIdentityService))], TextFileEditorModelManager));
|
|
415
439
|
|
|
416
440
|
export { TextFileEditorModelManager };
|
|
@@ -26,15 +26,15 @@ let TextFileSaveParticipant = class TextFileSaveParticipant extends Disposable {
|
|
|
26
26
|
const cts = ( new CancellationTokenSource(token));
|
|
27
27
|
model.textEditorModel?.pushStackElement();
|
|
28
28
|
progress.report({
|
|
29
|
-
message: ( localize(
|
|
29
|
+
message: ( localize(14706, "Running Code Actions and Formatters..."))
|
|
30
30
|
});
|
|
31
31
|
let bubbleCancel = false;
|
|
32
32
|
await this.progressService.withProgress({
|
|
33
33
|
priority: NotificationPriority.URGENT,
|
|
34
34
|
location: ProgressLocation.Notification,
|
|
35
|
-
cancellable: ( localize(
|
|
35
|
+
cancellable: ( localize(14707, "Skip")),
|
|
36
36
|
delay: model.isDirty() ? 5000 : 3000
|
|
37
|
-
}, async
|
|
37
|
+
}, async progress => {
|
|
38
38
|
const participants = Array.from(this.saveParticipants).sort((a, b) => {
|
|
39
39
|
const aValue = a.ordinal ?? 0;
|
|
40
40
|
const bValue = b.ordinal ?? 0;
|
|
@@ -47,12 +47,10 @@ let TextFileSaveParticipant = class TextFileSaveParticipant extends Disposable {
|
|
|
47
47
|
try {
|
|
48
48
|
const promise = saveParticipant.participate(model, context, progress, cts.token);
|
|
49
49
|
await raceCancellation(promise, cts.token);
|
|
50
|
-
}
|
|
51
|
-
catch (err) {
|
|
50
|
+
} catch (err) {
|
|
52
51
|
if (!isCancellationError(err)) {
|
|
53
52
|
this.logService.error(err);
|
|
54
|
-
}
|
|
55
|
-
else if (!cts.token.isCancellationRequested) {
|
|
53
|
+
} else if (!cts.token.isCancellationRequested) {
|
|
56
54
|
cts.cancel();
|
|
57
55
|
bubbleCancel = true;
|
|
58
56
|
}
|
|
@@ -72,9 +70,6 @@ let TextFileSaveParticipant = class TextFileSaveParticipant extends Disposable {
|
|
|
72
70
|
super.dispose();
|
|
73
71
|
}
|
|
74
72
|
};
|
|
75
|
-
TextFileSaveParticipant = ( __decorate([
|
|
76
|
-
( __param(0, ILogService)),
|
|
77
|
-
( __param(1, IProgressService))
|
|
78
|
-
], TextFileSaveParticipant));
|
|
73
|
+
TextFileSaveParticipant = ( __decorate([( __param(0, ILogService)), ( __param(1, IProgressService))], TextFileSaveParticipant));
|
|
79
74
|
|
|
80
75
|
export { TextFileSaveParticipant };
|