@codingame/monaco-vscode-files-service-override 9.0.2 → 10.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/files.js +43 -28
- package/package.json +2 -2
- package/vscode/src/vs/platform/files/browser/indexedDBFileSystemProvider.js +11 -11
- package/vscode/src/vs/platform/files/common/fileService.js +53 -53
- package/vscode/src/vs/platform/files/common/io.js +1 -1
- package/vscode/src/vs/workbench/services/files/browser/elevatedFileService.js +0 -1
- package/vscode/src/vs/workbench/services/textfile/browser/browserTextFileService.js +1 -3
- package/vscode/src/vs/workbench/services/textfile/browser/textFileService.js +23 -25
- package/vscode/src/vs/workbench/services/textfile/common/textFileEditorModelManager.js +7 -8
package/files.js
CHANGED
|
@@ -205,7 +205,10 @@ class RegisteredFileSystemProvider extends Disposable {
|
|
|
205
205
|
this.onDidChangeFile = this._onDidChangeFile.event;
|
|
206
206
|
this._bufferedChanges = [];
|
|
207
207
|
this.rootByAuthority = new Map();
|
|
208
|
-
this.capabilities =
|
|
208
|
+
this.capabilities =
|
|
209
|
+
2 |
|
|
210
|
+
1024 |
|
|
211
|
+
16 ;
|
|
209
212
|
if (readonly) {
|
|
210
213
|
this.capabilities |= 2048 ;
|
|
211
214
|
}
|
|
@@ -347,12 +350,14 @@ class RegisteredFileSystemProvider extends Disposable {
|
|
|
347
350
|
}
|
|
348
351
|
readFileStream(resource, opts, token) {
|
|
349
352
|
const file = this._lookupAsFile(resource, false);
|
|
350
|
-
const stream = newWriteableStream(data => VSBuffer.concat(( data.map(data => VSBuffer.wrap(data)))).buffer, {
|
|
353
|
+
const stream = newWriteableStream((data) => VSBuffer.concat(( data.map((data) => VSBuffer.wrap(data)))).buffer, {
|
|
351
354
|
highWaterMark: 10
|
|
352
355
|
});
|
|
353
356
|
void (async () => {
|
|
354
357
|
try {
|
|
355
|
-
if (file.readStream == null ||
|
|
358
|
+
if (file.readStream == null ||
|
|
359
|
+
typeof opts.length === 'number' ||
|
|
360
|
+
typeof opts.position === 'number') {
|
|
356
361
|
let buffer = await file.read();
|
|
357
362
|
if (typeof opts.position === 'number' || typeof opts.length === 'number') {
|
|
358
363
|
buffer = buffer.slice(opts.position ?? 0, opts.length);
|
|
@@ -428,7 +433,7 @@ class RegisteredFileSystemProvider extends Disposable {
|
|
|
428
433
|
return directory;
|
|
429
434
|
}
|
|
430
435
|
async mkdir() {
|
|
431
|
-
throw createFileSystemProviderError(
|
|
436
|
+
throw createFileSystemProviderError("Can' create a directory", FileSystemProviderErrorCode.NoPermissions);
|
|
432
437
|
}
|
|
433
438
|
deleteSync(resource) {
|
|
434
439
|
const node = this._lookup(resource, true);
|
|
@@ -436,7 +441,7 @@ class RegisteredFileSystemProvider extends Disposable {
|
|
|
436
441
|
throw createFileSystemProviderError('Not found', FileSystemProviderErrorCode.FileNotFound);
|
|
437
442
|
}
|
|
438
443
|
else if (node.type === FileType.Directory) {
|
|
439
|
-
throw createFileSystemProviderError(
|
|
444
|
+
throw createFileSystemProviderError("Can't delete a directory", FileSystemProviderErrorCode.NoPermissions);
|
|
440
445
|
}
|
|
441
446
|
node.delete();
|
|
442
447
|
}
|
|
@@ -466,14 +471,16 @@ class OverlayFileSystemProvider {
|
|
|
466
471
|
this.onDidChangeFile = this._onDidChangeFile.event;
|
|
467
472
|
this._onDidChangeOverlays = new Emitter();
|
|
468
473
|
this.onDidChangeOverlays = this._onDidChangeOverlays.event;
|
|
469
|
-
this.capabilities = 2 |
|
|
474
|
+
this.capabilities = 2 |
|
|
475
|
+
1024 |
|
|
476
|
+
16 ;
|
|
470
477
|
}
|
|
471
478
|
register(priority, provider) {
|
|
472
479
|
const item = { priority, provider };
|
|
473
480
|
this.providers.push(item);
|
|
474
481
|
this.providers.sort((a, b) => b.priority - a.priority);
|
|
475
482
|
const disposableStore = new DisposableStore();
|
|
476
|
-
disposableStore.add(provider.onDidChangeFile(e => {
|
|
483
|
+
disposableStore.add(provider.onDidChangeFile((e) => {
|
|
477
484
|
this._onDidChangeFile.fire(e);
|
|
478
485
|
}));
|
|
479
486
|
disposableStore.add({
|
|
@@ -505,11 +512,12 @@ class OverlayFileSystemProvider {
|
|
|
505
512
|
}
|
|
506
513
|
catch (err) {
|
|
507
514
|
firstError ?? (firstError = err);
|
|
508
|
-
if (err instanceof FileSystemProviderError &&
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
515
|
+
if (err instanceof FileSystemProviderError &&
|
|
516
|
+
[
|
|
517
|
+
FileSystemProviderErrorCode.NoPermissions,
|
|
518
|
+
FileSystemProviderErrorCode.FileNotFound,
|
|
519
|
+
FileSystemProviderErrorCode.Unavailable
|
|
520
|
+
].includes(err.code)) {
|
|
513
521
|
continue;
|
|
514
522
|
}
|
|
515
523
|
throw err;
|
|
@@ -529,11 +537,12 @@ class OverlayFileSystemProvider {
|
|
|
529
537
|
return await caller(provider);
|
|
530
538
|
}
|
|
531
539
|
catch (err) {
|
|
532
|
-
if (err instanceof FileSystemProviderError &&
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
540
|
+
if (err instanceof FileSystemProviderError &&
|
|
541
|
+
[
|
|
542
|
+
FileSystemProviderErrorCode.NoPermissions,
|
|
543
|
+
FileSystemProviderErrorCode.FileNotFound,
|
|
544
|
+
FileSystemProviderErrorCode.Unavailable
|
|
545
|
+
].includes(err.code)) {
|
|
537
546
|
continue;
|
|
538
547
|
}
|
|
539
548
|
throw err;
|
|
@@ -552,10 +561,10 @@ class OverlayFileSystemProvider {
|
|
|
552
561
|
});
|
|
553
562
|
}
|
|
554
563
|
async readFile(resource) {
|
|
555
|
-
return await this.readFromDelegates(delegate => delegate.readFile(resource));
|
|
564
|
+
return await this.readFromDelegates((delegate) => delegate.readFile(resource));
|
|
556
565
|
}
|
|
557
566
|
readFileStream(resource, opts, token) {
|
|
558
|
-
const writableStream = newWriteableStream(data => VSBuffer.concat(( data.map(data => VSBuffer.wrap(data)))).buffer);
|
|
567
|
+
const writableStream = newWriteableStream((data) => VSBuffer.concat(( data.map((data) => VSBuffer.wrap(data)))).buffer);
|
|
559
568
|
this.readFromDelegates(async (delegate) => {
|
|
560
569
|
if (hasFileReadStreamCapability(delegate)) {
|
|
561
570
|
const stream = delegate.readFileStream(resource, opts, token);
|
|
@@ -588,7 +597,7 @@ class OverlayFileSystemProvider {
|
|
|
588
597
|
}
|
|
589
598
|
return writableStream.end(data);
|
|
590
599
|
}
|
|
591
|
-
}, token).catch(err => {
|
|
600
|
+
}, token).catch((err) => {
|
|
592
601
|
writableStream.error(err);
|
|
593
602
|
});
|
|
594
603
|
return writableStream;
|
|
@@ -598,7 +607,10 @@ class OverlayFileSystemProvider {
|
|
|
598
607
|
if (!( results.some(isFullfiled))) {
|
|
599
608
|
throw results[0].reason;
|
|
600
609
|
}
|
|
601
|
-
return Object.entries(Object.fromEntries(( results
|
|
610
|
+
return Object.entries(Object.fromEntries(( results
|
|
611
|
+
.filter(isFullfiled)
|
|
612
|
+
.map((result) => result.value))
|
|
613
|
+
.flat()));
|
|
602
614
|
}
|
|
603
615
|
watch(resource, opts) {
|
|
604
616
|
const store = new DisposableStore();
|
|
@@ -622,13 +634,13 @@ class OverlayFileSystemProvider {
|
|
|
622
634
|
});
|
|
623
635
|
}
|
|
624
636
|
async mkdir(resource) {
|
|
625
|
-
await this.writeToDelegates(delegate => delegate.mkdir(resource));
|
|
637
|
+
await this.writeToDelegates((delegate) => delegate.mkdir(resource));
|
|
626
638
|
}
|
|
627
639
|
async delete(resource, opts) {
|
|
628
|
-
await this.writeToDelegates(delegate => delegate.delete(resource, opts));
|
|
640
|
+
await this.writeToDelegates((delegate) => delegate.delete(resource, opts));
|
|
629
641
|
}
|
|
630
642
|
async rename(from, to, opts) {
|
|
631
|
-
await this.writeToDelegates(delegate => delegate.rename(from, to, opts));
|
|
643
|
+
await this.writeToDelegates((delegate) => delegate.rename(from, to, opts));
|
|
632
644
|
}
|
|
633
645
|
}
|
|
634
646
|
class MkdirpOnWriteInMemoryFileSystemProvider extends InMemoryFileSystemProvider {
|
|
@@ -641,7 +653,7 @@ class DelegateFileSystemProvider {
|
|
|
641
653
|
constructor(options) {
|
|
642
654
|
this.options = options;
|
|
643
655
|
this.onDidChangeCapabilities = this.options.delegate.onDidChangeCapabilities;
|
|
644
|
-
this.onDidChangeFile = ( Event.map(this.options.delegate.onDidChangeFile, changes => ( changes.map(change => ({
|
|
656
|
+
this.onDidChangeFile = ( Event.map(this.options.delegate.onDidChangeFile, (changes) => ( changes.map((change) => ({
|
|
645
657
|
type: change.type,
|
|
646
658
|
resource: this.options.fromDeletate(change.resource)
|
|
647
659
|
})))));
|
|
@@ -656,7 +668,9 @@ class DelegateFileSystemProvider {
|
|
|
656
668
|
}
|
|
657
669
|
: undefined;
|
|
658
670
|
}
|
|
659
|
-
get capabilities() {
|
|
671
|
+
get capabilities() {
|
|
672
|
+
return this.options.delegate.capabilities;
|
|
673
|
+
}
|
|
660
674
|
watch(resource, opts) {
|
|
661
675
|
return this.options.delegate.watch(this.options.toDelegate(resource), opts);
|
|
662
676
|
}
|
|
@@ -735,7 +749,7 @@ let FileServiceOverride = class FileServiceOverride extends FileService {
|
|
|
735
749
|
});
|
|
736
750
|
}
|
|
737
751
|
if (provider instanceof IndexedDBFileSystemProvider) {
|
|
738
|
-
this._register(provider.onReportError(e => telemetryService.publicLog2('indexedDBFileSystemProviderError', e)));
|
|
752
|
+
this._register(provider.onReportError((e) => telemetryService.publicLog2('indexedDBFileSystemProviderError', e)));
|
|
739
753
|
}
|
|
740
754
|
}
|
|
741
755
|
}
|
|
@@ -774,7 +788,8 @@ async function initFile(file, content, options) {
|
|
|
774
788
|
return;
|
|
775
789
|
}
|
|
776
790
|
catch (error) {
|
|
777
|
-
if (!(error instanceof FileSystemProviderError) ||
|
|
791
|
+
if (!(error instanceof FileSystemProviderError) ||
|
|
792
|
+
error.code !== FileSystemProviderErrorCode.FileNotFound) {
|
|
778
793
|
console.error('Unable to check if file exists', error);
|
|
779
794
|
}
|
|
780
795
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-files-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.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@10.0.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -6,17 +6,17 @@ 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 { localize } from 'vscode/vscode/vs/nls';
|
|
9
|
-
import { createFileSystemProviderError, FileSystemProviderErrorCode, FileType,
|
|
9
|
+
import { createFileSystemProviderError, FileSystemProviderErrorCode, FileType, 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
|
|
|
13
|
-
const ERR_FILE_NOT_FOUND = createFileSystemProviderError(( localize(
|
|
14
|
-
const ERR_FILE_IS_DIR = createFileSystemProviderError(( localize(
|
|
15
|
-
const ERR_FILE_NOT_DIR = createFileSystemProviderError(( localize(
|
|
16
|
-
const ERR_DIR_NOT_EMPTY = createFileSystemProviderError(( localize(
|
|
17
|
-
const ERR_FILE_EXCEEDS_STORAGE_QUOTA = createFileSystemProviderError(( localize(
|
|
13
|
+
const ERR_FILE_NOT_FOUND = createFileSystemProviderError(( localize(595, "File does not exist")), FileSystemProviderErrorCode.FileNotFound);
|
|
14
|
+
const ERR_FILE_IS_DIR = createFileSystemProviderError(( localize(596, "File is Directory")), FileSystemProviderErrorCode.FileIsADirectory);
|
|
15
|
+
const ERR_FILE_NOT_DIR = createFileSystemProviderError(( localize(597, "File is not a directory")), FileSystemProviderErrorCode.FileNotADirectory);
|
|
16
|
+
const ERR_DIR_NOT_EMPTY = createFileSystemProviderError(( localize(598, "Directory is not empty")), FileSystemProviderErrorCode.Unknown);
|
|
17
|
+
const ERR_FILE_EXCEEDS_STORAGE_QUOTA = createFileSystemProviderError(( localize(599, "File exceeds available storage quota")), FileSystemProviderErrorCode.FileExceedsStorageQuota);
|
|
18
18
|
const ERR_UNKNOWN_INTERNAL = (message) => createFileSystemProviderError(( localize(
|
|
19
|
-
|
|
19
|
+
600,
|
|
20
20
|
"Internal error occurred in IndexedDB File System Provider. ({0})",
|
|
21
21
|
message
|
|
22
22
|
)), FileSystemProviderErrorCode.Unknown);
|
|
@@ -135,8 +135,8 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
135
135
|
this.scheme = scheme;
|
|
136
136
|
this.indexedDB = indexedDB;
|
|
137
137
|
this.store = store;
|
|
138
|
-
this.capabilities =
|
|
139
|
-
|
|
|
138
|
+
this.capabilities = 2
|
|
139
|
+
| 1024 ;
|
|
140
140
|
this.onDidChangeCapabilities = Event.None;
|
|
141
141
|
this.extUri = ( (new ExtUri(() => false))) ;
|
|
142
142
|
this._onDidChangeFile = this._register(( (new Emitter())));
|
|
@@ -304,7 +304,7 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
304
304
|
(await this.getFiletree()).delete(resource.path);
|
|
305
305
|
toDelete.forEach(key => this.mtimes.delete(key));
|
|
306
306
|
this.triggerChanges(( (toDelete.map(
|
|
307
|
-
path => ({ resource: resource.with({ path }), type:
|
|
307
|
+
path => ({ resource: resource.with({ path }), type: 2 })
|
|
308
308
|
))));
|
|
309
309
|
}
|
|
310
310
|
async tree(resource) {
|
|
@@ -353,7 +353,7 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
353
353
|
fileTree.add(resource.path, { type: 'file', size: content.byteLength });
|
|
354
354
|
this.mtimes.set(( (resource.toString())), Date.now());
|
|
355
355
|
}
|
|
356
|
-
this.triggerChanges(( (files.map(([resource]) => ({ resource, type:
|
|
356
|
+
this.triggerChanges(( (files.map(([resource]) => ({ resource, type: 0 })))));
|
|
357
357
|
}
|
|
358
358
|
async writeMany() {
|
|
359
359
|
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 { localize } from 'vscode/vscode/vs/nls';
|
|
16
|
-
import { FileType, toFileSystemProviderErrorCode, FileSystemProviderErrorCode, FileChangesEvent, FileOperationError,
|
|
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';
|
|
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';
|
|
@@ -34,7 +34,7 @@ async function mkdirp(providerExtUri, provider, directory) {
|
|
|
34
34
|
const stat = await provider.stat(directory);
|
|
35
35
|
if ((stat.type & FileType.Directory) === 0) {
|
|
36
36
|
throw ( (new Error(localize(
|
|
37
|
-
|
|
37
|
+
601,
|
|
38
38
|
"Unable to create folder '{0}' that already exists but is not a directory",
|
|
39
39
|
resourceForError(directory)
|
|
40
40
|
))));
|
|
@@ -149,17 +149,17 @@ let FileService = class FileService extends Disposable {
|
|
|
149
149
|
async withProvider(resource) {
|
|
150
150
|
if (!isAbsolutePath(resource)) {
|
|
151
151
|
throw ( (new FileOperationError(localize(
|
|
152
|
-
|
|
152
|
+
602,
|
|
153
153
|
"Unable to resolve filesystem provider with relative file path '{0}'",
|
|
154
154
|
this.resourceForError(resource)
|
|
155
|
-
),
|
|
155
|
+
), 8 )));
|
|
156
156
|
}
|
|
157
157
|
await this.activateProvider(resource.scheme);
|
|
158
158
|
const provider = this.provider.get(resource.scheme);
|
|
159
159
|
if (!provider) {
|
|
160
160
|
const error = ( (new ErrorNoTelemetry()));
|
|
161
161
|
error.message = ( localize(
|
|
162
|
-
|
|
162
|
+
603,
|
|
163
163
|
"ENOPRO: No file system provider found for resource '{0}'",
|
|
164
164
|
(resource.toString())
|
|
165
165
|
));
|
|
@@ -192,10 +192,10 @@ let FileService = class FileService extends Disposable {
|
|
|
192
192
|
catch (error) {
|
|
193
193
|
if (toFileSystemProviderErrorCode(error) === FileSystemProviderErrorCode.FileNotFound) {
|
|
194
194
|
throw ( (new FileOperationError(localize(
|
|
195
|
-
|
|
195
|
+
604,
|
|
196
196
|
"Unable to resolve nonexistent file '{0}'",
|
|
197
197
|
this.resourceForError(resource)
|
|
198
|
-
),
|
|
198
|
+
), 1 )));
|
|
199
199
|
}
|
|
200
200
|
throw ensureFileSystemProviderError(error);
|
|
201
201
|
}
|
|
@@ -236,7 +236,7 @@ let FileService = class FileService extends Disposable {
|
|
|
236
236
|
mtime: stat.mtime,
|
|
237
237
|
ctime: stat.ctime,
|
|
238
238
|
size: stat.size,
|
|
239
|
-
readonly: Boolean((stat.permissions ?? 0) & FilePermission.Readonly) || Boolean(provider.capabilities &
|
|
239
|
+
readonly: Boolean((stat.permissions ?? 0) & FilePermission.Readonly) || Boolean(provider.capabilities & 2048 ),
|
|
240
240
|
locked: Boolean((stat.permissions ?? 0) & FilePermission.Locked),
|
|
241
241
|
etag: etag({ mtime: stat.mtime, size: stat.size }),
|
|
242
242
|
children: undefined
|
|
@@ -303,16 +303,16 @@ let FileService = class FileService extends Disposable {
|
|
|
303
303
|
async doValidateCreateFile(resource, options) {
|
|
304
304
|
if (!options?.overwrite && (await this.exists(resource))) {
|
|
305
305
|
throw ( (new FileOperationError(localize(
|
|
306
|
-
|
|
306
|
+
605,
|
|
307
307
|
"Unable to create file '{0}' that already exists when overwrite flag is not set",
|
|
308
308
|
this.resourceForError(resource)
|
|
309
|
-
),
|
|
309
|
+
), 3 , options)));
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
async createFile(resource, bufferOrReadableOrStream = VSBuffer.fromString(''), options) {
|
|
313
313
|
await this.doValidateCreateFile(resource, options);
|
|
314
314
|
const fileStat = await this.writeFile(resource, bufferOrReadableOrStream);
|
|
315
|
-
this._onDidRunOperation.fire(( (new FileOperationEvent(resource,
|
|
315
|
+
this._onDidRunOperation.fire(( (new FileOperationEvent(resource, 0 , fileStat))));
|
|
316
316
|
return fileStat;
|
|
317
317
|
}
|
|
318
318
|
async writeFile(resource, bufferOrReadableOrStream, options) {
|
|
@@ -357,11 +357,11 @@ let FileService = class FileService extends Disposable {
|
|
|
357
357
|
else {
|
|
358
358
|
await this.doWriteBuffered(provider, resource, writeFileOptions, bufferOrReadableOrStreamOrBufferedStream instanceof VSBuffer ? bufferToReadable(bufferOrReadableOrStreamOrBufferedStream) : bufferOrReadableOrStreamOrBufferedStream);
|
|
359
359
|
}
|
|
360
|
-
this._onDidRunOperation.fire(( (new FileOperationEvent(resource,
|
|
360
|
+
this._onDidRunOperation.fire(( (new FileOperationEvent(resource, 4 ))));
|
|
361
361
|
}
|
|
362
362
|
catch (error) {
|
|
363
363
|
throw ( (new FileOperationError(localize(
|
|
364
|
-
|
|
364
|
+
606,
|
|
365
365
|
"Unable to write file '{0}' ({1})",
|
|
366
366
|
this.resourceForError(resource),
|
|
367
367
|
( (ensureFileSystemProviderError(error).toString()))
|
|
@@ -371,32 +371,32 @@ let FileService = class FileService extends Disposable {
|
|
|
371
371
|
}
|
|
372
372
|
async validateWriteFile(provider, resource, options) {
|
|
373
373
|
const unlock = !!options?.unlock;
|
|
374
|
-
if (unlock && !(provider.capabilities &
|
|
374
|
+
if (unlock && !((provider.capabilities & 8192) )) {
|
|
375
375
|
throw ( (new Error(localize(
|
|
376
|
-
|
|
376
|
+
607,
|
|
377
377
|
"Unable to unlock file '{0}' because provider does not support it.",
|
|
378
378
|
this.resourceForError(resource)
|
|
379
379
|
))));
|
|
380
380
|
}
|
|
381
381
|
const atomic = !!options?.atomic;
|
|
382
382
|
if (atomic) {
|
|
383
|
-
if (!(provider.capabilities &
|
|
383
|
+
if (!((provider.capabilities & 32768) )) {
|
|
384
384
|
throw ( (new Error(localize(
|
|
385
|
-
|
|
385
|
+
608,
|
|
386
386
|
"Unable to atomically write file '{0}' because provider does not support it.",
|
|
387
387
|
this.resourceForError(resource)
|
|
388
388
|
))));
|
|
389
389
|
}
|
|
390
|
-
if (!(provider.capabilities &
|
|
390
|
+
if (!((provider.capabilities & 2) )) {
|
|
391
391
|
throw ( (new Error(localize(
|
|
392
|
-
|
|
392
|
+
609,
|
|
393
393
|
"Unable to atomically write file '{0}' because provider does not support unbuffered writes.",
|
|
394
394
|
this.resourceForError(resource)
|
|
395
395
|
))));
|
|
396
396
|
}
|
|
397
397
|
if (unlock) {
|
|
398
398
|
throw ( (new Error(localize(
|
|
399
|
-
|
|
399
|
+
610,
|
|
400
400
|
"Unable to unlock file '{0}' because atomic write is enabled.",
|
|
401
401
|
this.resourceForError(resource)
|
|
402
402
|
))));
|
|
@@ -411,18 +411,18 @@ let FileService = class FileService extends Disposable {
|
|
|
411
411
|
}
|
|
412
412
|
if ((stat.type & FileType.Directory) !== 0) {
|
|
413
413
|
throw ( (new FileOperationError(localize(
|
|
414
|
-
|
|
414
|
+
611,
|
|
415
415
|
"Unable to write file '{0}' that is actually a directory",
|
|
416
416
|
this.resourceForError(resource)
|
|
417
|
-
),
|
|
417
|
+
), 0 , options)));
|
|
418
418
|
}
|
|
419
419
|
this.throwIfFileIsReadonly(resource, stat);
|
|
420
420
|
if (typeof options?.mtime === 'number' && typeof options.etag === 'string' && options.etag !== ETAG_DISABLED &&
|
|
421
421
|
typeof stat.mtime === 'number' && typeof stat.size === 'number' &&
|
|
422
422
|
options.mtime < stat.mtime && options.etag !== etag({ mtime: options.mtime , size: stat.size })) {
|
|
423
423
|
throw ( (new FileOperationError(
|
|
424
|
-
localize(
|
|
425
|
-
|
|
424
|
+
localize(612, "File Modified Since"),
|
|
425
|
+
3 ,
|
|
426
426
|
options
|
|
427
427
|
)));
|
|
428
428
|
}
|
|
@@ -508,7 +508,7 @@ let FileService = class FileService extends Disposable {
|
|
|
508
508
|
}
|
|
509
509
|
restoreReadError(error, resource, options) {
|
|
510
510
|
const message = ( localize(
|
|
511
|
-
|
|
511
|
+
613,
|
|
512
512
|
"Unable to read file '{0}' ({1})",
|
|
513
513
|
this.resourceForError(resource),
|
|
514
514
|
(ensureFileSystemProviderError(error).toString())
|
|
@@ -574,13 +574,13 @@ let FileService = class FileService extends Disposable {
|
|
|
574
574
|
const stat = await this.resolve(resource, { resolveMetadata: true });
|
|
575
575
|
if (stat.isDirectory) {
|
|
576
576
|
throw ( (new FileOperationError(localize(
|
|
577
|
-
|
|
577
|
+
614,
|
|
578
578
|
"Unable to read file '{0}' that is actually a directory",
|
|
579
579
|
this.resourceForError(resource)
|
|
580
|
-
),
|
|
580
|
+
), 0 , options)));
|
|
581
581
|
}
|
|
582
582
|
if (typeof options?.etag === 'string' && options.etag !== ETAG_DISABLED && options.etag === stat.etag) {
|
|
583
|
-
throw ( (new NotModifiedSinceFileOperationError(localize(
|
|
583
|
+
throw ( (new NotModifiedSinceFileOperationError(localize(615, "File not modified since"), stat, options)));
|
|
584
584
|
}
|
|
585
585
|
this.validateReadFileLimits(resource, stat.size, options);
|
|
586
586
|
return stat;
|
|
@@ -588,10 +588,10 @@ let FileService = class FileService extends Disposable {
|
|
|
588
588
|
validateReadFileLimits(resource, size, options) {
|
|
589
589
|
if (typeof options?.limits?.size === 'number' && size > options.limits.size) {
|
|
590
590
|
throw ( (new TooLargeFileOperationError(localize(
|
|
591
|
-
|
|
591
|
+
616,
|
|
592
592
|
"Unable to read file '{0}' that is too large to open",
|
|
593
593
|
this.resourceForError(resource)
|
|
594
|
-
),
|
|
594
|
+
), 7 , size, options)));
|
|
595
595
|
}
|
|
596
596
|
}
|
|
597
597
|
async canMove(source, target, overwrite) {
|
|
@@ -620,7 +620,7 @@ let FileService = class FileService extends Disposable {
|
|
|
620
620
|
const fileStat = await this.resolve(target, { resolveMetadata: true });
|
|
621
621
|
this._onDidRunOperation.fire(( (new FileOperationEvent(
|
|
622
622
|
source,
|
|
623
|
-
mode === 'move' ?
|
|
623
|
+
mode === 'move' ? 2 : 3 ,
|
|
624
624
|
fileStat
|
|
625
625
|
))));
|
|
626
626
|
return fileStat;
|
|
@@ -632,7 +632,7 @@ let FileService = class FileService extends Disposable {
|
|
|
632
632
|
const fileStat = await this.resolve(target, { resolveMetadata: true });
|
|
633
633
|
this._onDidRunOperation.fire(( (new FileOperationEvent(
|
|
634
634
|
source,
|
|
635
|
-
mode === 'copy' ?
|
|
635
|
+
mode === 'copy' ? 3 : 2 ,
|
|
636
636
|
fileStat
|
|
637
637
|
))));
|
|
638
638
|
return fileStat;
|
|
@@ -710,7 +710,7 @@ let FileService = class FileService extends Disposable {
|
|
|
710
710
|
}
|
|
711
711
|
if (isSameResourceWithDifferentPathCase && mode === 'copy') {
|
|
712
712
|
throw ( (new Error(localize(
|
|
713
|
-
|
|
713
|
+
617,
|
|
714
714
|
"Unable to copy when source '{0}' is same as target '{1}' with different path case on a case insensitive file system",
|
|
715
715
|
this.resourceForError(source),
|
|
716
716
|
this.resourceForError(target)
|
|
@@ -718,7 +718,7 @@ let FileService = class FileService extends Disposable {
|
|
|
718
718
|
}
|
|
719
719
|
if (!isSameResourceWithDifferentPathCase && providerExtUri.isEqualOrParent(target, source)) {
|
|
720
720
|
throw ( (new Error(localize(
|
|
721
|
-
|
|
721
|
+
618,
|
|
722
722
|
"Unable to move/copy when source '{0}' is parent of target '{1}'.",
|
|
723
723
|
this.resourceForError(source),
|
|
724
724
|
this.resourceForError(target)
|
|
@@ -729,17 +729,17 @@ let FileService = class FileService extends Disposable {
|
|
|
729
729
|
if (exists && !isSameResourceWithDifferentPathCase) {
|
|
730
730
|
if (!overwrite) {
|
|
731
731
|
throw ( (new FileOperationError(localize(
|
|
732
|
-
|
|
732
|
+
619,
|
|
733
733
|
"Unable to move/copy '{0}' because target '{1}' already exists at destination.",
|
|
734
734
|
this.resourceForError(source),
|
|
735
735
|
this.resourceForError(target)
|
|
736
|
-
),
|
|
736
|
+
), 4 )));
|
|
737
737
|
}
|
|
738
738
|
if (sourceProvider === targetProvider) {
|
|
739
739
|
const { providerExtUri } = this.getExtUri(sourceProvider);
|
|
740
740
|
if (providerExtUri.isEqualOrParent(source, target)) {
|
|
741
741
|
throw ( (new Error(localize(
|
|
742
|
-
|
|
742
|
+
620,
|
|
743
743
|
"Unable to move/copy '{0}' into '{1}' since a file would replace the folder it is contained in.",
|
|
744
744
|
this.resourceForError(source),
|
|
745
745
|
this.resourceForError(target)
|
|
@@ -757,13 +757,13 @@ let FileService = class FileService extends Disposable {
|
|
|
757
757
|
};
|
|
758
758
|
}
|
|
759
759
|
isPathCaseSensitive(provider) {
|
|
760
|
-
return !!(provider.capabilities &
|
|
760
|
+
return !!((provider.capabilities & 1024) );
|
|
761
761
|
}
|
|
762
762
|
async createFolder(resource) {
|
|
763
763
|
const provider = this.throwIfFileSystemIsReadonly(await this.withProvider(resource), resource);
|
|
764
764
|
await this.mkdirp(provider, resource);
|
|
765
765
|
const fileStat = await this.resolve(resource, { resolveMetadata: true });
|
|
766
|
-
this._onDidRunOperation.fire(( (new FileOperationEvent(resource,
|
|
766
|
+
this._onDidRunOperation.fire(( (new FileOperationEvent(resource, 0 , fileStat))));
|
|
767
767
|
return fileStat;
|
|
768
768
|
}
|
|
769
769
|
async mkdirp(provider, directory) {
|
|
@@ -782,24 +782,24 @@ let FileService = class FileService extends Disposable {
|
|
|
782
782
|
async doValidateDelete(resource, options) {
|
|
783
783
|
const provider = this.throwIfFileSystemIsReadonly(await this.withProvider(resource), resource);
|
|
784
784
|
const useTrash = !!options?.useTrash;
|
|
785
|
-
if (useTrash && !(provider.capabilities &
|
|
785
|
+
if (useTrash && !((provider.capabilities & 4096) )) {
|
|
786
786
|
throw ( (new Error(localize(
|
|
787
|
-
|
|
787
|
+
621,
|
|
788
788
|
"Unable to delete file '{0}' via trash because provider does not support it.",
|
|
789
789
|
this.resourceForError(resource)
|
|
790
790
|
))));
|
|
791
791
|
}
|
|
792
792
|
const atomic = options?.atomic;
|
|
793
|
-
if (atomic && !(provider.capabilities &
|
|
793
|
+
if (atomic && !((provider.capabilities & 65536) )) {
|
|
794
794
|
throw ( (new Error(localize(
|
|
795
|
-
|
|
795
|
+
622,
|
|
796
796
|
"Unable to delete file '{0}' atomically because provider does not support it.",
|
|
797
797
|
this.resourceForError(resource)
|
|
798
798
|
))));
|
|
799
799
|
}
|
|
800
800
|
if (useTrash && atomic) {
|
|
801
801
|
throw ( (new Error(localize(
|
|
802
|
-
|
|
802
|
+
623,
|
|
803
803
|
"Unable to atomically delete file '{0}' because using trash is enabled.",
|
|
804
804
|
this.resourceForError(resource)
|
|
805
805
|
))));
|
|
@@ -815,17 +815,17 @@ let FileService = class FileService extends Disposable {
|
|
|
815
815
|
}
|
|
816
816
|
else {
|
|
817
817
|
throw ( (new FileOperationError(localize(
|
|
818
|
-
|
|
818
|
+
624,
|
|
819
819
|
"Unable to delete nonexistent file '{0}'",
|
|
820
820
|
this.resourceForError(resource)
|
|
821
|
-
),
|
|
821
|
+
), 1 )));
|
|
822
822
|
}
|
|
823
823
|
const recursive = !!options?.recursive;
|
|
824
824
|
if (!recursive) {
|
|
825
825
|
const stat = await this.resolve(resource);
|
|
826
826
|
if (stat.isDirectory && Array.isArray(stat.children) && stat.children.length > 0) {
|
|
827
827
|
throw ( (new Error(localize(
|
|
828
|
-
|
|
828
|
+
625,
|
|
829
829
|
"Unable to delete non-empty folder '{0}'.",
|
|
830
830
|
this.resourceForError(resource)
|
|
831
831
|
))));
|
|
@@ -846,7 +846,7 @@ let FileService = class FileService extends Disposable {
|
|
|
846
846
|
const recursive = !!deleteFileOptions?.recursive;
|
|
847
847
|
const atomic = deleteFileOptions?.atomic ?? false;
|
|
848
848
|
await provider.delete(resource, { recursive, useTrash, atomic });
|
|
849
|
-
this._onDidRunOperation.fire(( (new FileOperationEvent(resource,
|
|
849
|
+
this._onDidRunOperation.fire(( (new FileOperationEvent(resource, 1 ))));
|
|
850
850
|
}
|
|
851
851
|
async cloneFile(source, target) {
|
|
852
852
|
const sourceProvider = await this.withProvider(source);
|
|
@@ -1084,22 +1084,22 @@ let FileService = class FileService extends Disposable {
|
|
|
1084
1084
|
await this.doWriteUnbuffered(targetProvider, target, undefined, buffer);
|
|
1085
1085
|
}
|
|
1086
1086
|
throwIfFileSystemIsReadonly(provider, resource) {
|
|
1087
|
-
if (provider.capabilities &
|
|
1087
|
+
if (provider.capabilities & 2048 ) {
|
|
1088
1088
|
throw ( (new FileOperationError(localize(
|
|
1089
|
-
|
|
1089
|
+
626,
|
|
1090
1090
|
"Unable to modify read-only file '{0}'",
|
|
1091
1091
|
this.resourceForError(resource)
|
|
1092
|
-
),
|
|
1092
|
+
), 6 )));
|
|
1093
1093
|
}
|
|
1094
1094
|
return provider;
|
|
1095
1095
|
}
|
|
1096
1096
|
throwIfFileIsReadonly(resource, stat) {
|
|
1097
1097
|
if ((stat.permissions ?? 0) & FilePermission.Readonly) {
|
|
1098
1098
|
throw ( (new FileOperationError(localize(
|
|
1099
|
-
|
|
1099
|
+
626,
|
|
1100
1100
|
"Unable to modify read-only file '{0}'",
|
|
1101
1101
|
this.resourceForError(resource)
|
|
1102
|
-
),
|
|
1102
|
+
), 6 )));
|
|
1103
1103
|
}
|
|
1104
1104
|
}
|
|
1105
1105
|
resourceForError(resource) {
|
|
@@ -69,7 +69,7 @@ function throwIfCancelled(token) {
|
|
|
69
69
|
}
|
|
70
70
|
function throwIfTooLarge(totalBytesRead, options) {
|
|
71
71
|
if (typeof options?.limits?.size === 'number' && totalBytesRead > options.limits.size) {
|
|
72
|
-
throw createFileSystemProviderError(localize(
|
|
72
|
+
throw createFileSystemProviderError(localize(4473, "File is too large to open"), FileSystemProviderErrorCode.FileTooLarge);
|
|
73
73
|
}
|
|
74
74
|
return true;
|
|
75
75
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
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';
|
|
4
3
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
5
|
-
import 'vscode/vscode/vs/platform/instantiation/common/extensions';
|
|
6
4
|
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
7
5
|
import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
|
|
8
6
|
import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
|
|
@@ -29,7 +27,7 @@ let BrowserTextFileService = class BrowserTextFileService extends AbstractTextFi
|
|
|
29
27
|
this._register(this.lifecycleService.onBeforeShutdown(event => event.veto(this.onBeforeShutdown(), 'veto.textFiles')));
|
|
30
28
|
}
|
|
31
29
|
onBeforeShutdown() {
|
|
32
|
-
if (( this.files.models.some(model => model.hasState(
|
|
30
|
+
if (( this.files.models.some(model => model.hasState(2 )))) {
|
|
33
31
|
return true;
|
|
34
32
|
}
|
|
35
33
|
return false;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import { localize } from 'vscode/vscode/vs/nls';
|
|
3
|
-
import {
|
|
3
|
+
import { TextFileOperationError, 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';
|
|
7
6
|
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
8
7
|
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
9
8
|
import { extname } from 'vscode/vscode/vs/base/common/path';
|
|
@@ -28,7 +27,7 @@ import { IWorkingCopyFileService } from 'vscode/vscode/vs/workbench/services/wor
|
|
|
28
27
|
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
|
|
29
28
|
import { WORKSPACE_EXTENSION } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
30
29
|
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
|
|
31
|
-
import { UTF8,
|
|
30
|
+
import { UTF8, toEncodeReadable, toDecodeStream, UTF16be, UTF16le, UTF8_with_bom, encodingExists } from 'vscode/vscode/vs/workbench/services/textfile/common/encoding';
|
|
32
31
|
import { consumeStream } from 'vscode/vscode/vs/base/common/stream';
|
|
33
32
|
import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
|
|
34
33
|
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
@@ -48,13 +47,12 @@ import 'vscode/vscode/vs/platform/theme/common/colors/minimapColors';
|
|
|
48
47
|
import 'vscode/vscode/vs/platform/theme/common/colors/miscColors';
|
|
49
48
|
import 'vscode/vscode/vs/platform/theme/common/colors/quickpickColors';
|
|
50
49
|
import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
|
|
51
|
-
import { firstOrDefault } from 'vscode/vscode/vs/base/common/arrays';
|
|
52
50
|
|
|
53
51
|
var AbstractTextFileService_1;
|
|
54
52
|
let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
55
53
|
static { AbstractTextFileService_1 = this; }
|
|
56
|
-
static { this.TEXTFILE_SAVE_CREATE_SOURCE = SaveSourceRegistry.registerSource('textFileCreate.source', ( localize(
|
|
57
|
-
static { this.TEXTFILE_SAVE_REPLACE_SOURCE = SaveSourceRegistry.registerSource('textFileOverwrite.source', ( localize(
|
|
54
|
+
static { this.TEXTFILE_SAVE_CREATE_SOURCE = SaveSourceRegistry.registerSource('textFileCreate.source', ( localize(4474, "File Created"))); }
|
|
55
|
+
static { this.TEXTFILE_SAVE_REPLACE_SOURCE = SaveSourceRegistry.registerSource('textFileOverwrite.source', ( localize(4475, "File Replaced"))); }
|
|
58
56
|
constructor(fileService, untitledTextEditorService, lifecycleService, instantiationService, modelService, environmentService, dialogService, fileDialogService, textResourceConfigurationService, filesConfigurationService, codeEditorService, pathService, workingCopyFileService, uriIdentityService, languageService, logService, elevatedFileService, decorationsService) {
|
|
59
57
|
super();
|
|
60
58
|
this.fileService = fileService;
|
|
@@ -84,14 +82,14 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
84
82
|
constructor(files) {
|
|
85
83
|
super();
|
|
86
84
|
this.files = files;
|
|
87
|
-
this.label = ( localize(
|
|
85
|
+
this.label = ( localize(4476, "Text File Model Decorations"));
|
|
88
86
|
this._onDidChange = this._register(( (new Emitter())));
|
|
89
87
|
this.onDidChange = this._onDidChange.event;
|
|
90
88
|
this.registerListeners();
|
|
91
89
|
}
|
|
92
90
|
registerListeners() {
|
|
93
91
|
this._register(this.files.onDidResolve(({ model }) => {
|
|
94
|
-
if (model.isReadonly() || model.hasState(
|
|
92
|
+
if (model.isReadonly() || model.hasState(4 )) {
|
|
95
93
|
this._onDidChange.fire([model.resource]);
|
|
96
94
|
}
|
|
97
95
|
}));
|
|
@@ -105,26 +103,26 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
105
103
|
return undefined;
|
|
106
104
|
}
|
|
107
105
|
const isReadonly = model.isReadonly();
|
|
108
|
-
const isOrphaned = model.hasState(
|
|
106
|
+
const isOrphaned = model.hasState(4 );
|
|
109
107
|
if (isReadonly && isOrphaned) {
|
|
110
108
|
return {
|
|
111
109
|
color: listErrorForeground,
|
|
112
110
|
letter: Codicon.lockSmall,
|
|
113
111
|
strikethrough: true,
|
|
114
|
-
tooltip: ( localize(
|
|
112
|
+
tooltip: ( localize(4477, "Deleted, Read-only")),
|
|
115
113
|
};
|
|
116
114
|
}
|
|
117
115
|
else if (isReadonly) {
|
|
118
116
|
return {
|
|
119
117
|
letter: Codicon.lockSmall,
|
|
120
|
-
tooltip: ( localize(
|
|
118
|
+
tooltip: ( localize(4478, "Read-only")),
|
|
121
119
|
};
|
|
122
120
|
}
|
|
123
121
|
else if (isOrphaned) {
|
|
124
122
|
return {
|
|
125
123
|
color: listErrorForeground,
|
|
126
124
|
strikethrough: true,
|
|
127
|
-
tooltip: ( localize(
|
|
125
|
+
tooltip: ( localize(4479, "Deleted")),
|
|
128
126
|
};
|
|
129
127
|
}
|
|
130
128
|
return undefined;
|
|
@@ -176,10 +174,10 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
176
174
|
}
|
|
177
175
|
catch (error) {
|
|
178
176
|
cts.dispose(true);
|
|
179
|
-
if (error.decodeStreamErrorKind ===
|
|
177
|
+
if (error.decodeStreamErrorKind === 1 ) {
|
|
180
178
|
throw ( (new TextFileOperationError(
|
|
181
|
-
localize(
|
|
182
|
-
|
|
179
|
+
localize(4480, "File seems to be binary and cannot be opened as text"),
|
|
180
|
+
0 ,
|
|
183
181
|
options
|
|
184
182
|
)));
|
|
185
183
|
}
|
|
@@ -334,8 +332,8 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
334
332
|
}
|
|
335
333
|
catch (error) {
|
|
336
334
|
if (targetExists) {
|
|
337
|
-
if (error.textFileOperationResult ===
|
|
338
|
-
error.fileOperationResult ===
|
|
335
|
+
if (error.textFileOperationResult === 0 ||
|
|
336
|
+
error.fileOperationResult === 7 ) {
|
|
339
337
|
await this.fileService.del(target);
|
|
340
338
|
return this.doSaveAsTextFile(sourceModel, source, target, options);
|
|
341
339
|
}
|
|
@@ -396,17 +394,17 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
396
394
|
const { confirmed } = await this.dialogService.confirm({
|
|
397
395
|
type: 'warning',
|
|
398
396
|
message: ( localize(
|
|
399
|
-
|
|
397
|
+
4481,
|
|
400
398
|
"'{0}' already exists. Do you want to replace it?",
|
|
401
399
|
basename(resource)
|
|
402
400
|
)),
|
|
403
401
|
detail: ( localize(
|
|
404
|
-
|
|
402
|
+
4482,
|
|
405
403
|
"A file or folder with the name '{0}' already exists in the folder '{1}'. Replacing it will overwrite its current contents.",
|
|
406
404
|
basename(resource),
|
|
407
405
|
basename(dirname(resource))
|
|
408
406
|
)),
|
|
409
|
-
primaryButton: ( localize(
|
|
407
|
+
primaryButton: ( localize(4483, "&&Replace")),
|
|
410
408
|
});
|
|
411
409
|
return confirmed;
|
|
412
410
|
}
|
|
@@ -414,12 +412,12 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
414
412
|
const { confirmed } = await this.dialogService.confirm({
|
|
415
413
|
type: 'warning',
|
|
416
414
|
message: ( localize(
|
|
417
|
-
|
|
415
|
+
4484,
|
|
418
416
|
"'{0}' is marked as read-only. Do you want to save anyway?",
|
|
419
417
|
basename(resource)
|
|
420
418
|
)),
|
|
421
|
-
detail: ( localize(
|
|
422
|
-
primaryButton: ( localize(
|
|
419
|
+
detail: ( localize(4485, "Paths can be configured as read-only via settings.")),
|
|
420
|
+
primaryButton: ( localize(4486, "&&Save Anyway"))
|
|
423
421
|
});
|
|
424
422
|
return confirmed;
|
|
425
423
|
}
|
|
@@ -467,7 +465,7 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
467
465
|
if (extensions.includes(untitledExtension)) {
|
|
468
466
|
return untitledName;
|
|
469
467
|
}
|
|
470
|
-
const primaryExtension =
|
|
468
|
+
const primaryExtension = extensions.at(0);
|
|
471
469
|
if (primaryExtension) {
|
|
472
470
|
if (untitledExtension) {
|
|
473
471
|
return `${untitledName.substring(0, untitledName.indexOf(untitledExtension))}${primaryExtension}`;
|
|
@@ -478,7 +476,7 @@ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
|
478
476
|
if (filenames.includes(untitledName)) {
|
|
479
477
|
return untitledName;
|
|
480
478
|
}
|
|
481
|
-
return
|
|
479
|
+
return filenames.at(0) ?? untitledName;
|
|
482
480
|
}
|
|
483
481
|
async revert(resource, options) {
|
|
484
482
|
if (resource.scheme === Schemas.untitled) {
|
|
@@ -7,7 +7,6 @@ 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';
|
|
11
10
|
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
12
11
|
import { ResourceQueue, Promises } from 'vscode/vscode/vs/base/common/async';
|
|
13
12
|
import { onUnexpectedError } from 'vscode/vscode/vs/base/common/errors';
|
|
@@ -62,7 +61,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
62
61
|
return {
|
|
63
62
|
onSaveError(error, model) {
|
|
64
63
|
notificationService.error(( localize(
|
|
65
|
-
|
|
64
|
+
9901,
|
|
66
65
|
"Failed to save '{0}': {1}",
|
|
67
66
|
model.name,
|
|
68
67
|
toErrorMessage(error, false)
|
|
@@ -87,7 +86,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
87
86
|
if (model.isDirty()) {
|
|
88
87
|
continue;
|
|
89
88
|
}
|
|
90
|
-
if (e.contains(model.resource,
|
|
89
|
+
if (e.contains(model.resource, 0 , 1 )) {
|
|
91
90
|
this.queueModelReload(model);
|
|
92
91
|
}
|
|
93
92
|
}
|
|
@@ -125,7 +124,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
onWillRunWorkingCopyFileOperation(e) {
|
|
128
|
-
if (e.operation ===
|
|
127
|
+
if (e.operation === 2 || e.operation === 3 ) {
|
|
129
128
|
const modelsToRestore = [];
|
|
130
129
|
for (const { source, target } of e.files) {
|
|
131
130
|
if (source) {
|
|
@@ -161,7 +160,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
161
160
|
}
|
|
162
161
|
}
|
|
163
162
|
onDidFailWorkingCopyFileOperation(e) {
|
|
164
|
-
if ((e.operation ===
|
|
163
|
+
if (((e.operation === 2 || e.operation === 3) )) {
|
|
165
164
|
const modelsToRestore = this.mapCorrelationIdToModelsToRestore.get(e.correlationId);
|
|
166
165
|
if (modelsToRestore) {
|
|
167
166
|
this.mapCorrelationIdToModelsToRestore.delete(e.correlationId);
|
|
@@ -175,7 +174,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
175
174
|
}
|
|
176
175
|
onDidRunWorkingCopyFileOperation(e) {
|
|
177
176
|
switch (e.operation) {
|
|
178
|
-
case
|
|
177
|
+
case 0 :
|
|
179
178
|
e.waitUntil((async () => {
|
|
180
179
|
for (const { target } of e.files) {
|
|
181
180
|
const model = this.get(target);
|
|
@@ -185,8 +184,8 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
|
|
|
185
184
|
}
|
|
186
185
|
})());
|
|
187
186
|
break;
|
|
188
|
-
case
|
|
189
|
-
case
|
|
187
|
+
case 2 :
|
|
188
|
+
case 3 :
|
|
190
189
|
e.waitUntil((async () => {
|
|
191
190
|
const modelsToRestore = this.mapCorrelationIdToModelsToRestore.get(e.correlationId);
|
|
192
191
|
if (modelsToRestore) {
|