@codingame/monaco-vscode-files-service-override 5.2.0 → 6.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 +5 -5
- package/vscode/src/vs/platform/files/common/fileService.js +26 -26
- package/vscode/src/vs/workbench/services/files/browser/elevatedFileService.js +1 -0
- package/vscode/src/vs/workbench/services/textfile/browser/browserTextFileService.js +3 -1
- package/vscode/src/vs/workbench/services/textfile/browser/textFileService.js +9 -8
- package/vscode/src/vs/workbench/services/textfile/common/textFileEditorModelManager.js +13 -9
- package/vscode/src/vs/workbench/services/textfile/common/textFileSaveParticipant.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-files-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"vscode": "npm:@codingame/monaco-vscode-api@
|
|
29
|
+
"vscode": "npm:@codingame/monaco-vscode-api@6.0.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -6,7 +6,7 @@ import { ExtUri } from 'vscode/vscode/vs/base/common/resources';
|
|
|
6
6
|
import { isString } from 'vscode/vscode/vs/base/common/types';
|
|
7
7
|
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
8
8
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
9
|
-
import { createFileSystemProviderError, FileSystemProviderErrorCode, FileType, FileSystemProviderError } from 'vscode/vscode/vs/platform/files/common/files';
|
|
9
|
+
import { createFileSystemProviderError, FileSystemProviderErrorCode, FileType, FileSystemProviderCapabilities, FileChangeType, FileSystemProviderError } from 'vscode/vscode/vs/platform/files/common/files';
|
|
10
10
|
import { DBClosedError } from 'vscode/vscode/vs/base/browser/indexedDB';
|
|
11
11
|
import { BroadcastDataChannel } from 'vscode/vscode/vs/base/browser/broadcast';
|
|
12
12
|
|
|
@@ -137,8 +137,8 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
137
137
|
this.scheme = scheme;
|
|
138
138
|
this.indexedDB = indexedDB;
|
|
139
139
|
this.store = store;
|
|
140
|
-
this.capabilities =
|
|
141
|
-
|
|
|
140
|
+
this.capabilities = FileSystemProviderCapabilities.FileReadWrite
|
|
141
|
+
| FileSystemProviderCapabilities.PathCaseSensitive;
|
|
142
142
|
this.onDidChangeCapabilities = Event.None;
|
|
143
143
|
this.extUri = ( (new ExtUri(() => false))) ;
|
|
144
144
|
this._onDidChangeFile = this._register(( (new Emitter())));
|
|
@@ -306,7 +306,7 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
306
306
|
(await this.getFiletree()).delete(resource.path);
|
|
307
307
|
toDelete.forEach(key => this.mtimes.delete(key));
|
|
308
308
|
this.triggerChanges(( (toDelete.map(
|
|
309
|
-
path => ({ resource: resource.with({ path }), type:
|
|
309
|
+
path => ({ resource: resource.with({ path }), type: FileChangeType.DELETED })
|
|
310
310
|
))));
|
|
311
311
|
}
|
|
312
312
|
async tree(resource) {
|
|
@@ -355,7 +355,7 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
355
355
|
fileTree.add(resource.path, { type: 'file', size: content.byteLength });
|
|
356
356
|
this.mtimes.set(( (resource.toString())), Date.now());
|
|
357
357
|
}
|
|
358
|
-
this.triggerChanges(( (files.map(([resource]) => ({ resource, type:
|
|
358
|
+
this.triggerChanges(( (files.map(([resource]) => ({ resource, type: FileChangeType.UPDATED })))));
|
|
359
359
|
}
|
|
360
360
|
async writeMany() {
|
|
361
361
|
if (this.fileWriteBatch.length) {
|
|
@@ -13,7 +13,7 @@ import { mark } from 'vscode/vscode/vs/base/common/performance';
|
|
|
13
13
|
import { isAbsolutePath, extUri, extUriIgnorePathCase } from 'vscode/vscode/vs/base/common/resources';
|
|
14
14
|
import { isReadableStream, peekStream, peekReadable, consumeStream, transform, newWriteableStream, isReadableBufferedStream, listenStream } from 'vscode/vscode/vs/base/common/stream';
|
|
15
15
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
16
|
-
import { FileType, toFileSystemProviderErrorCode, FileSystemProviderErrorCode, FileChangesEvent, FileOperationError, hasOpenReadWriteCloseCapability, hasReadWriteCapability, hasFileReadStreamCapability, ensureFileSystemProviderError, FilePermission, etag, FileOperationEvent, hasFileAtomicWriteCapability, toFileOperationResult, ETAG_DISABLED, hasFileAtomicReadCapability, NotModifiedSinceFileOperationError, TooLargeFileOperationError, hasFileFolderCopyCapability, hasFileAtomicDeleteCapability, hasFileCloneCapability } from 'vscode/vscode/vs/platform/files/common/files';
|
|
16
|
+
import { FileType, toFileSystemProviderErrorCode, FileSystemProviderErrorCode, FileChangesEvent, FileOperationError, FileOperationResult, hasOpenReadWriteCloseCapability, hasReadWriteCapability, hasFileReadStreamCapability, ensureFileSystemProviderError, FilePermission, FileSystemProviderCapabilities, etag, FileOperationEvent, FileOperation, hasFileAtomicWriteCapability, toFileOperationResult, ETAG_DISABLED, hasFileAtomicReadCapability, NotModifiedSinceFileOperationError, TooLargeFileOperationError, hasFileFolderCopyCapability, hasFileAtomicDeleteCapability, hasFileCloneCapability } from 'vscode/vscode/vs/platform/files/common/files';
|
|
17
17
|
import { readFileIntoStream } from './io.js';
|
|
18
18
|
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
19
19
|
import { ErrorNoTelemetry } from 'vscode/vscode/vs/base/common/errors';
|
|
@@ -155,7 +155,7 @@ let FileService = class FileService extends Disposable {
|
|
|
155
155
|
1,
|
|
156
156
|
"Unable to resolve filesystem provider with relative file path '{0}'",
|
|
157
157
|
this.resourceForError(resource)
|
|
158
|
-
),
|
|
158
|
+
), FileOperationResult.FILE_INVALID_PATH)));
|
|
159
159
|
}
|
|
160
160
|
await this.activateProvider(resource.scheme);
|
|
161
161
|
const provider = this.provider.get(resource.scheme);
|
|
@@ -200,7 +200,7 @@ let FileService = class FileService extends Disposable {
|
|
|
200
200
|
3,
|
|
201
201
|
"Unable to resolve nonexistent file '{0}'",
|
|
202
202
|
this.resourceForError(resource)
|
|
203
|
-
),
|
|
203
|
+
), FileOperationResult.FILE_NOT_FOUND)));
|
|
204
204
|
}
|
|
205
205
|
throw ensureFileSystemProviderError(error);
|
|
206
206
|
}
|
|
@@ -241,7 +241,7 @@ let FileService = class FileService extends Disposable {
|
|
|
241
241
|
mtime: stat.mtime,
|
|
242
242
|
ctime: stat.ctime,
|
|
243
243
|
size: stat.size,
|
|
244
|
-
readonly: Boolean((stat.permissions ?? 0) & FilePermission.Readonly) || Boolean(provider.capabilities &
|
|
244
|
+
readonly: Boolean((stat.permissions ?? 0) & FilePermission.Readonly) || Boolean(provider.capabilities & FileSystemProviderCapabilities.Readonly),
|
|
245
245
|
locked: Boolean((stat.permissions ?? 0) & FilePermission.Locked),
|
|
246
246
|
etag: etag({ mtime: stat.mtime, size: stat.size }),
|
|
247
247
|
children: undefined
|
|
@@ -312,13 +312,13 @@ let FileService = class FileService extends Disposable {
|
|
|
312
312
|
4,
|
|
313
313
|
"Unable to create file '{0}' that already exists when overwrite flag is not set",
|
|
314
314
|
this.resourceForError(resource)
|
|
315
|
-
),
|
|
315
|
+
), FileOperationResult.FILE_MODIFIED_SINCE, options)));
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
async createFile(resource, bufferOrReadableOrStream = VSBuffer.fromString(''), options) {
|
|
319
319
|
await this.doValidateCreateFile(resource, options);
|
|
320
320
|
const fileStat = await this.writeFile(resource, bufferOrReadableOrStream);
|
|
321
|
-
this._onDidRunOperation.fire(( (new FileOperationEvent(resource,
|
|
321
|
+
this._onDidRunOperation.fire(( (new FileOperationEvent(resource, FileOperation.CREATE, fileStat))));
|
|
322
322
|
return fileStat;
|
|
323
323
|
}
|
|
324
324
|
async writeFile(resource, bufferOrReadableOrStream, options) {
|
|
@@ -363,7 +363,7 @@ let FileService = class FileService extends Disposable {
|
|
|
363
363
|
else {
|
|
364
364
|
await this.doWriteBuffered(provider, resource, writeFileOptions, bufferOrReadableOrStreamOrBufferedStream instanceof VSBuffer ? bufferToReadable(bufferOrReadableOrStreamOrBufferedStream) : bufferOrReadableOrStreamOrBufferedStream);
|
|
365
365
|
}
|
|
366
|
-
this._onDidRunOperation.fire(( (new FileOperationEvent(resource,
|
|
366
|
+
this._onDidRunOperation.fire(( (new FileOperationEvent(resource, FileOperation.WRITE))));
|
|
367
367
|
}
|
|
368
368
|
catch (error) {
|
|
369
369
|
throw ( (new FileOperationError(localizeWithPath(
|
|
@@ -378,7 +378,7 @@ let FileService = class FileService extends Disposable {
|
|
|
378
378
|
}
|
|
379
379
|
async validateWriteFile(provider, resource, options) {
|
|
380
380
|
const unlock = !!options?.unlock;
|
|
381
|
-
if (unlock && !(
|
|
381
|
+
if (unlock && !(provider.capabilities & FileSystemProviderCapabilities.FileWriteUnlock)) {
|
|
382
382
|
throw ( (new Error(localizeWithPath(
|
|
383
383
|
_moduleId,
|
|
384
384
|
6,
|
|
@@ -388,7 +388,7 @@ let FileService = class FileService extends Disposable {
|
|
|
388
388
|
}
|
|
389
389
|
const atomic = !!options?.atomic;
|
|
390
390
|
if (atomic) {
|
|
391
|
-
if (!(
|
|
391
|
+
if (!(provider.capabilities & FileSystemProviderCapabilities.FileAtomicWrite)) {
|
|
392
392
|
throw ( (new Error(localizeWithPath(
|
|
393
393
|
_moduleId,
|
|
394
394
|
7,
|
|
@@ -396,7 +396,7 @@ let FileService = class FileService extends Disposable {
|
|
|
396
396
|
this.resourceForError(resource)
|
|
397
397
|
))));
|
|
398
398
|
}
|
|
399
|
-
if (!(
|
|
399
|
+
if (!(provider.capabilities & FileSystemProviderCapabilities.FileReadWrite)) {
|
|
400
400
|
throw ( (new Error(localizeWithPath(
|
|
401
401
|
_moduleId,
|
|
402
402
|
8,
|
|
@@ -426,7 +426,7 @@ let FileService = class FileService extends Disposable {
|
|
|
426
426
|
10,
|
|
427
427
|
"Unable to write file '{0}' that is actually a directory",
|
|
428
428
|
this.resourceForError(resource)
|
|
429
|
-
),
|
|
429
|
+
), FileOperationResult.FILE_IS_DIRECTORY, options)));
|
|
430
430
|
}
|
|
431
431
|
this.throwIfFileIsReadonly(resource, stat);
|
|
432
432
|
if (typeof options?.mtime === 'number' && typeof options.etag === 'string' && options.etag !== ETAG_DISABLED &&
|
|
@@ -434,7 +434,7 @@ let FileService = class FileService extends Disposable {
|
|
|
434
434
|
options.mtime < stat.mtime && options.etag !== etag({ mtime: options.mtime , size: stat.size })) {
|
|
435
435
|
throw ( (new FileOperationError(
|
|
436
436
|
localizeWithPath(_moduleId, 11, "File Modified Since"),
|
|
437
|
-
|
|
437
|
+
FileOperationResult.FILE_MODIFIED_SINCE,
|
|
438
438
|
options
|
|
439
439
|
)));
|
|
440
440
|
}
|
|
@@ -591,7 +591,7 @@ let FileService = class FileService extends Disposable {
|
|
|
591
591
|
13,
|
|
592
592
|
"Unable to read file '{0}' that is actually a directory",
|
|
593
593
|
this.resourceForError(resource)
|
|
594
|
-
),
|
|
594
|
+
), FileOperationResult.FILE_IS_DIRECTORY, options)));
|
|
595
595
|
}
|
|
596
596
|
if (typeof options?.etag === 'string' && options.etag !== ETAG_DISABLED && options.etag === stat.etag) {
|
|
597
597
|
throw ( (new NotModifiedSinceFileOperationError(localizeWithPath(_moduleId, 14, "File not modified since"), stat, options)));
|
|
@@ -606,7 +606,7 @@ let FileService = class FileService extends Disposable {
|
|
|
606
606
|
15,
|
|
607
607
|
"Unable to read file '{0}' that is too large to open",
|
|
608
608
|
this.resourceForError(resource)
|
|
609
|
-
),
|
|
609
|
+
), FileOperationResult.FILE_TOO_LARGE, size, options)));
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
612
|
async canMove(source, target, overwrite) {
|
|
@@ -635,7 +635,7 @@ let FileService = class FileService extends Disposable {
|
|
|
635
635
|
const fileStat = await this.resolve(target, { resolveMetadata: true });
|
|
636
636
|
this._onDidRunOperation.fire(( (new FileOperationEvent(
|
|
637
637
|
source,
|
|
638
|
-
mode === 'move' ?
|
|
638
|
+
mode === 'move' ? FileOperation.MOVE : FileOperation.COPY,
|
|
639
639
|
fileStat
|
|
640
640
|
))));
|
|
641
641
|
return fileStat;
|
|
@@ -647,7 +647,7 @@ let FileService = class FileService extends Disposable {
|
|
|
647
647
|
const fileStat = await this.resolve(target, { resolveMetadata: true });
|
|
648
648
|
this._onDidRunOperation.fire(( (new FileOperationEvent(
|
|
649
649
|
source,
|
|
650
|
-
mode === 'copy' ?
|
|
650
|
+
mode === 'copy' ? FileOperation.COPY : FileOperation.MOVE,
|
|
651
651
|
fileStat
|
|
652
652
|
))));
|
|
653
653
|
return fileStat;
|
|
@@ -751,7 +751,7 @@ let FileService = class FileService extends Disposable {
|
|
|
751
751
|
"Unable to move/copy '{0}' because target '{1}' already exists at destination.",
|
|
752
752
|
this.resourceForError(source),
|
|
753
753
|
this.resourceForError(target)
|
|
754
|
-
),
|
|
754
|
+
), FileOperationResult.FILE_MOVE_CONFLICT)));
|
|
755
755
|
}
|
|
756
756
|
if (sourceProvider === targetProvider) {
|
|
757
757
|
const { providerExtUri } = this.getExtUri(sourceProvider);
|
|
@@ -776,13 +776,13 @@ let FileService = class FileService extends Disposable {
|
|
|
776
776
|
};
|
|
777
777
|
}
|
|
778
778
|
isPathCaseSensitive(provider) {
|
|
779
|
-
return !!(
|
|
779
|
+
return !!(provider.capabilities & FileSystemProviderCapabilities.PathCaseSensitive);
|
|
780
780
|
}
|
|
781
781
|
async createFolder(resource) {
|
|
782
782
|
const provider = this.throwIfFileSystemIsReadonly(await this.withProvider(resource), resource);
|
|
783
783
|
await this.mkdirp(provider, resource);
|
|
784
784
|
const fileStat = await this.resolve(resource, { resolveMetadata: true });
|
|
785
|
-
this._onDidRunOperation.fire(( (new FileOperationEvent(resource,
|
|
785
|
+
this._onDidRunOperation.fire(( (new FileOperationEvent(resource, FileOperation.CREATE, fileStat))));
|
|
786
786
|
return fileStat;
|
|
787
787
|
}
|
|
788
788
|
async mkdirp(provider, directory) {
|
|
@@ -801,7 +801,7 @@ let FileService = class FileService extends Disposable {
|
|
|
801
801
|
async doValidateDelete(resource, options) {
|
|
802
802
|
const provider = this.throwIfFileSystemIsReadonly(await this.withProvider(resource), resource);
|
|
803
803
|
const useTrash = !!options?.useTrash;
|
|
804
|
-
if (useTrash && !(
|
|
804
|
+
if (useTrash && !(provider.capabilities & FileSystemProviderCapabilities.Trash)) {
|
|
805
805
|
throw ( (new Error(localizeWithPath(
|
|
806
806
|
_moduleId,
|
|
807
807
|
20,
|
|
@@ -810,7 +810,7 @@ let FileService = class FileService extends Disposable {
|
|
|
810
810
|
))));
|
|
811
811
|
}
|
|
812
812
|
const atomic = options?.atomic;
|
|
813
|
-
if (atomic && !(
|
|
813
|
+
if (atomic && !(provider.capabilities & FileSystemProviderCapabilities.FileAtomicDelete)) {
|
|
814
814
|
throw ( (new Error(localizeWithPath(
|
|
815
815
|
_moduleId,
|
|
816
816
|
21,
|
|
@@ -841,7 +841,7 @@ let FileService = class FileService extends Disposable {
|
|
|
841
841
|
23,
|
|
842
842
|
"Unable to delete nonexistent file '{0}'",
|
|
843
843
|
this.resourceForError(resource)
|
|
844
|
-
),
|
|
844
|
+
), FileOperationResult.FILE_NOT_FOUND)));
|
|
845
845
|
}
|
|
846
846
|
const recursive = !!options?.recursive;
|
|
847
847
|
if (!recursive) {
|
|
@@ -870,7 +870,7 @@ let FileService = class FileService extends Disposable {
|
|
|
870
870
|
const recursive = !!deleteFileOptions?.recursive;
|
|
871
871
|
const atomic = deleteFileOptions?.atomic ?? false;
|
|
872
872
|
await provider.delete(resource, { recursive, useTrash, atomic });
|
|
873
|
-
this._onDidRunOperation.fire(( (new FileOperationEvent(resource,
|
|
873
|
+
this._onDidRunOperation.fire(( (new FileOperationEvent(resource, FileOperation.DELETE))));
|
|
874
874
|
}
|
|
875
875
|
async cloneFile(source, target) {
|
|
876
876
|
const sourceProvider = await this.withProvider(source);
|
|
@@ -1108,13 +1108,13 @@ let FileService = class FileService extends Disposable {
|
|
|
1108
1108
|
await this.doWriteUnbuffered(targetProvider, target, undefined, buffer);
|
|
1109
1109
|
}
|
|
1110
1110
|
throwIfFileSystemIsReadonly(provider, resource) {
|
|
1111
|
-
if (provider.capabilities &
|
|
1111
|
+
if (provider.capabilities & FileSystemProviderCapabilities.Readonly) {
|
|
1112
1112
|
throw ( (new FileOperationError(localizeWithPath(
|
|
1113
1113
|
_moduleId,
|
|
1114
1114
|
25,
|
|
1115
1115
|
"Unable to modify read-only file '{0}'",
|
|
1116
1116
|
this.resourceForError(resource)
|
|
1117
|
-
),
|
|
1117
|
+
), FileOperationResult.FILE_PERMISSION_DENIED)));
|
|
1118
1118
|
}
|
|
1119
1119
|
return provider;
|
|
1120
1120
|
}
|
|
@@ -1125,7 +1125,7 @@ let FileService = class FileService extends Disposable {
|
|
|
1125
1125
|
25,
|
|
1126
1126
|
"Unable to modify read-only file '{0}'",
|
|
1127
1127
|
this.resourceForError(resource)
|
|
1128
|
-
),
|
|
1128
|
+
), FileOperationResult.FILE_PERMISSION_DENIED)));
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
1131
1131
|
resourceForError(resource) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import { AbstractTextFileService } from './textFileService.js';
|
|
3
|
+
import { TextFileEditorModelState } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
|
|
3
4
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
5
|
+
import 'vscode/vscode/vs/platform/instantiation/common/extensions';
|
|
4
6
|
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
5
7
|
import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
|
|
6
8
|
import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
|
|
@@ -27,7 +29,7 @@ let BrowserTextFileService = class BrowserTextFileService extends AbstractTextFi
|
|
|
27
29
|
this._register(this.lifecycleService.onBeforeShutdown(event => event.veto(this.onBeforeShutdown(), 'veto.textFiles')));
|
|
28
30
|
}
|
|
29
31
|
onBeforeShutdown() {
|
|
30
|
-
if (( this.files.models.some(model => model.hasState(
|
|
32
|
+
if (( this.files.models.some(model => model.hasState(TextFileEditorModelState.PENDING_SAVE)))) {
|
|
31
33
|
return true;
|
|
32
34
|
}
|
|
33
35
|
return false;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
3
|
-
import { TextFileOperationError, toBufferOrReadable, stringToSnapshot } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
|
|
3
|
+
import { TextFileEditorModelState, TextFileOperationError, TextFileOperationResult, toBufferOrReadable, stringToSnapshot } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
|
|
4
4
|
import { SaveSourceRegistry } from 'vscode/vscode/vs/workbench/common/editor';
|
|
5
5
|
import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
|
|
6
|
+
import { FileOperationResult } from 'vscode/vscode/vs/platform/files/common/files';
|
|
6
7
|
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
7
8
|
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
8
9
|
import { extname } from 'vscode/vscode/vs/base/common/path';
|
|
@@ -27,7 +28,7 @@ import { IWorkingCopyFileService } from 'vscode/vscode/vs/workbench/services/wor
|
|
|
27
28
|
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
|
|
28
29
|
import { WORKSPACE_EXTENSION } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
29
30
|
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
|
|
30
|
-
import { UTF8, toEncodeReadable, toDecodeStream, UTF16be, UTF16le, UTF8_with_bom, encodingExists } from 'vscode/vscode/vs/workbench/services/textfile/common/encoding';
|
|
31
|
+
import { UTF8, DecodeStreamErrorKind, toEncodeReadable, toDecodeStream, UTF16be, UTF16le, UTF8_with_bom, encodingExists } from 'vscode/vscode/vs/workbench/services/textfile/common/encoding';
|
|
31
32
|
import { consumeStream } from 'vscode/vscode/vs/base/common/stream';
|
|
32
33
|
import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
|
|
33
34
|
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
@@ -91,7 +92,7 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
91
92
|
}
|
|
92
93
|
registerListeners() {
|
|
93
94
|
this._register(this.files.onDidResolve(({ model }) => {
|
|
94
|
-
if (model.isReadonly() || model.hasState(
|
|
95
|
+
if (model.isReadonly() || model.hasState(TextFileEditorModelState.ORPHAN)) {
|
|
95
96
|
this._onDidChange.fire([model.resource]);
|
|
96
97
|
}
|
|
97
98
|
}));
|
|
@@ -105,7 +106,7 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
105
106
|
return undefined;
|
|
106
107
|
}
|
|
107
108
|
const isReadonly = model.isReadonly();
|
|
108
|
-
const isOrphaned = model.hasState(
|
|
109
|
+
const isOrphaned = model.hasState(TextFileEditorModelState.ORPHAN);
|
|
109
110
|
if (isReadonly && isOrphaned) {
|
|
110
111
|
return {
|
|
111
112
|
color: listErrorForeground,
|
|
@@ -176,10 +177,10 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
176
177
|
}
|
|
177
178
|
catch (error) {
|
|
178
179
|
cts.dispose(true);
|
|
179
|
-
if (error.decodeStreamErrorKind ===
|
|
180
|
+
if (error.decodeStreamErrorKind === DecodeStreamErrorKind.STREAM_IS_BINARY) {
|
|
180
181
|
throw ( (new TextFileOperationError(
|
|
181
182
|
localizeWithPath(_moduleId, 6, "File seems to be binary and cannot be opened as text"),
|
|
182
|
-
|
|
183
|
+
TextFileOperationResult.FILE_IS_BINARY,
|
|
183
184
|
options
|
|
184
185
|
)));
|
|
185
186
|
}
|
|
@@ -331,8 +332,8 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
331
332
|
}
|
|
332
333
|
catch (error) {
|
|
333
334
|
if (targetExists) {
|
|
334
|
-
if (error.textFileOperationResult ===
|
|
335
|
-
error.fileOperationResult ===
|
|
335
|
+
if (error.textFileOperationResult === TextFileOperationResult.FILE_IS_BINARY ||
|
|
336
|
+
error.fileOperationResult === FileOperationResult.FILE_TOO_LARGE) {
|
|
336
337
|
await this.fileService.del(target);
|
|
337
338
|
return this.doSaveAsTextFile(sourceModel, source, target, options);
|
|
338
339
|
}
|
|
@@ -7,6 +7,7 @@ import { TextFileEditorModel } from 'vscode/vscode/vs/workbench/services/textfil
|
|
|
7
7
|
import { Disposable, DisposableStore, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
8
8
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
9
9
|
import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
|
|
10
|
+
import { FileChangeType, FileOperation } from 'vscode/vscode/vs/platform/files/common/files';
|
|
10
11
|
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
11
12
|
import { ResourceQueue, Promises } from 'vscode/vscode/vs/base/common/async';
|
|
12
13
|
import { onUnexpectedError } from 'vscode/vscode/vs/base/common/errors';
|
|
@@ -30,7 +31,9 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
30
31
|
this.notificationService = notificationService;
|
|
31
32
|
this.workingCopyFileService = workingCopyFileService;
|
|
32
33
|
this.uriIdentityService = uriIdentityService;
|
|
33
|
-
this._onDidCreate = this._register(( (new Emitter(
|
|
34
|
+
this._onDidCreate = this._register(( (new Emitter(
|
|
35
|
+
{ leakWarningThreshold: 500 }
|
|
36
|
+
))));
|
|
34
37
|
this.onDidCreate = this._onDidCreate.event;
|
|
35
38
|
this._onDidResolve = this._register(( (new Emitter())));
|
|
36
39
|
this.onDidResolve = this._onDidResolve.event;
|
|
@@ -86,7 +89,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
86
89
|
if (model.isDirty()) {
|
|
87
90
|
continue;
|
|
88
91
|
}
|
|
89
|
-
if (e.contains(model.resource,
|
|
92
|
+
if (e.contains(model.resource, FileChangeType.UPDATED, FileChangeType.ADDED)) {
|
|
90
93
|
this.queueModelReload(model);
|
|
91
94
|
}
|
|
92
95
|
}
|
|
@@ -124,7 +127,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
onWillRunWorkingCopyFileOperation(e) {
|
|
127
|
-
if (e.operation ===
|
|
130
|
+
if (e.operation === FileOperation.MOVE || e.operation === FileOperation.COPY) {
|
|
128
131
|
const modelsToRestore = [];
|
|
129
132
|
for (const { source, target } of e.files) {
|
|
130
133
|
if (source) {
|
|
@@ -160,7 +163,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
160
163
|
}
|
|
161
164
|
}
|
|
162
165
|
onDidFailWorkingCopyFileOperation(e) {
|
|
163
|
-
if ((
|
|
166
|
+
if ((e.operation === FileOperation.MOVE || e.operation === FileOperation.COPY)) {
|
|
164
167
|
const modelsToRestore = this.mapCorrelationIdToModelsToRestore.get(e.correlationId);
|
|
165
168
|
if (modelsToRestore) {
|
|
166
169
|
this.mapCorrelationIdToModelsToRestore.delete(e.correlationId);
|
|
@@ -174,7 +177,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
174
177
|
}
|
|
175
178
|
onDidRunWorkingCopyFileOperation(e) {
|
|
176
179
|
switch (e.operation) {
|
|
177
|
-
case
|
|
180
|
+
case FileOperation.CREATE:
|
|
178
181
|
e.waitUntil((async () => {
|
|
179
182
|
for (const { target } of e.files) {
|
|
180
183
|
const model = this.get(target);
|
|
@@ -184,14 +187,15 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
184
187
|
}
|
|
185
188
|
})());
|
|
186
189
|
break;
|
|
187
|
-
case
|
|
188
|
-
case
|
|
190
|
+
case FileOperation.MOVE:
|
|
191
|
+
case FileOperation.COPY:
|
|
189
192
|
e.waitUntil((async () => {
|
|
190
193
|
const modelsToRestore = this.mapCorrelationIdToModelsToRestore.get(e.correlationId);
|
|
191
194
|
if (modelsToRestore) {
|
|
192
195
|
this.mapCorrelationIdToModelsToRestore.delete(e.correlationId);
|
|
193
196
|
await Promises.settled(( (modelsToRestore.map(async (modelToRestore) => {
|
|
194
|
-
const
|
|
197
|
+
const target = this.uriIdentityService.asCanonicalUri(modelToRestore.target);
|
|
198
|
+
const restoredModel = await this.resolve(target, {
|
|
195
199
|
reload: { async: false },
|
|
196
200
|
contents: modelToRestore.snapshot ? createTextBufferFactoryFromSnapshot(modelToRestore.snapshot) : undefined,
|
|
197
201
|
encoding: modelToRestore.encoding
|
|
@@ -199,7 +203,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
199
203
|
if (modelToRestore.languageId &&
|
|
200
204
|
modelToRestore.languageId !== PLAINTEXT_LANGUAGE_ID &&
|
|
201
205
|
restoredModel.getLanguageId() === PLAINTEXT_LANGUAGE_ID &&
|
|
202
|
-
extname(
|
|
206
|
+
extname(target) !== PLAINTEXT_EXTENSION) {
|
|
203
207
|
restoredModel.updateTextEditorModel(undefined, modelToRestore.languageId);
|
|
204
208
|
}
|
|
205
209
|
}))));
|
|
@@ -3,6 +3,7 @@ import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
|
3
3
|
import { raceCancellation } from 'vscode/vscode/vs/base/common/async';
|
|
4
4
|
import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
|
|
5
5
|
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
6
|
+
import { ProgressLocation } from 'vscode/vscode/vs/platform/progress/common/progress';
|
|
6
7
|
import { IProgressService } from 'vscode/vscode/vs/platform/progress/common/progress.service';
|
|
7
8
|
import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
8
9
|
import { insert } from 'vscode/vscode/vs/base/common/arrays';
|
|
@@ -23,7 +24,7 @@ let TextFileSaveParticipant = class TextFileSaveParticipant extends Disposable {
|
|
|
23
24
|
const cts = ( (new CancellationTokenSource(token)));
|
|
24
25
|
return this.progressService.withProgress({
|
|
25
26
|
title: ( localizeWithPath(_moduleId, 0, "Saving '{0}'", model.name)),
|
|
26
|
-
location:
|
|
27
|
+
location: ProgressLocation.Notification,
|
|
27
28
|
cancellable: true,
|
|
28
29
|
delay: model.isDirty() ? 3000 : 5000
|
|
29
30
|
}, async (progress) => {
|