@codingame/monaco-vscode-files-service-override 10.1.4 → 11.0.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-files-service-override",
3
- "version": "10.1.4",
3
+ "version": "11.0.1",
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@10.1.4"
29
+ "vscode": "npm:@codingame/monaco-vscode-api@11.0.1"
30
30
  }
31
31
  }
@@ -10,13 +10,13 @@ import { createFileSystemProviderError, FileSystemProviderErrorCode, FileType, F
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(740, "File does not exist")), FileSystemProviderErrorCode.FileNotFound);
14
- const ERR_FILE_IS_DIR = createFileSystemProviderError(( localize(741, "File is Directory")), FileSystemProviderErrorCode.FileIsADirectory);
15
- const ERR_FILE_NOT_DIR = createFileSystemProviderError(( localize(742, "File is not a directory")), FileSystemProviderErrorCode.FileNotADirectory);
16
- const ERR_DIR_NOT_EMPTY = createFileSystemProviderError(( localize(743, "Directory is not empty")), FileSystemProviderErrorCode.Unknown);
17
- const ERR_FILE_EXCEEDS_STORAGE_QUOTA = createFileSystemProviderError(( localize(744, "File exceeds available storage quota")), FileSystemProviderErrorCode.FileExceedsStorageQuota);
13
+ const ERR_FILE_NOT_FOUND = createFileSystemProviderError(( localize(736, "File does not exist")), FileSystemProviderErrorCode.FileNotFound);
14
+ const ERR_FILE_IS_DIR = createFileSystemProviderError(( localize(737, "File is Directory")), FileSystemProviderErrorCode.FileIsADirectory);
15
+ const ERR_FILE_NOT_DIR = createFileSystemProviderError(( localize(738, "File is not a directory")), FileSystemProviderErrorCode.FileNotADirectory);
16
+ const ERR_DIR_NOT_EMPTY = createFileSystemProviderError(( localize(739, "Directory is not empty")), FileSystemProviderErrorCode.Unknown);
17
+ const ERR_FILE_EXCEEDS_STORAGE_QUOTA = createFileSystemProviderError(( localize(740, "File exceeds available storage quota")), FileSystemProviderErrorCode.FileExceedsStorageQuota);
18
18
  const ERR_UNKNOWN_INTERNAL = (message) => createFileSystemProviderError(( localize(
19
- 745,
19
+ 741,
20
20
  "Internal error occurred in IndexedDB File System Provider. ({0})",
21
21
  message
22
22
  )), FileSystemProviderErrorCode.Unknown);
@@ -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
- 712,
37
+ 708,
38
38
  "Unable to create folder '{0}' that already exists but is not a directory",
39
39
  resourceForError(directory)
40
40
  ))));
@@ -149,7 +149,7 @@ let FileService = class FileService extends Disposable {
149
149
  async withProvider(resource) {
150
150
  if (!isAbsolutePath(resource)) {
151
151
  throw ( (new FileOperationError(localize(
152
- 713,
152
+ 709,
153
153
  "Unable to resolve filesystem provider with relative file path '{0}'",
154
154
  this.resourceForError(resource)
155
155
  ), 8 )));
@@ -159,7 +159,7 @@ let FileService = class FileService extends Disposable {
159
159
  if (!provider) {
160
160
  const error = ( (new ErrorNoTelemetry()));
161
161
  error.message = ( localize(
162
- 714,
162
+ 710,
163
163
  "ENOPRO: No file system provider found for resource '{0}'",
164
164
  (resource.toString())
165
165
  ));
@@ -192,7 +192,7 @@ let FileService = class FileService extends Disposable {
192
192
  catch (error) {
193
193
  if (toFileSystemProviderErrorCode(error) === FileSystemProviderErrorCode.FileNotFound) {
194
194
  throw ( (new FileOperationError(localize(
195
- 715,
195
+ 711,
196
196
  "Unable to resolve nonexistent file '{0}'",
197
197
  this.resourceForError(resource)
198
198
  ), 1 )));
@@ -303,7 +303,7 @@ 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
- 716,
306
+ 712,
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)));
@@ -361,7 +361,7 @@ let FileService = class FileService extends Disposable {
361
361
  }
362
362
  catch (error) {
363
363
  throw ( (new FileOperationError(localize(
364
- 717,
364
+ 713,
365
365
  "Unable to write file '{0}' ({1})",
366
366
  this.resourceForError(resource),
367
367
  ( (ensureFileSystemProviderError(error).toString()))
@@ -373,7 +373,7 @@ let FileService = class FileService extends Disposable {
373
373
  const unlock = !!options?.unlock;
374
374
  if (unlock && !((provider.capabilities & 8192) )) {
375
375
  throw ( (new Error(localize(
376
- 718,
376
+ 714,
377
377
  "Unable to unlock file '{0}' because provider does not support it.",
378
378
  this.resourceForError(resource)
379
379
  ))));
@@ -382,21 +382,21 @@ let FileService = class FileService extends Disposable {
382
382
  if (atomic) {
383
383
  if (!((provider.capabilities & 32768) )) {
384
384
  throw ( (new Error(localize(
385
- 719,
385
+ 715,
386
386
  "Unable to atomically write file '{0}' because provider does not support it.",
387
387
  this.resourceForError(resource)
388
388
  ))));
389
389
  }
390
390
  if (!((provider.capabilities & 2) )) {
391
391
  throw ( (new Error(localize(
392
- 720,
392
+ 716,
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
- 721,
399
+ 717,
400
400
  "Unable to unlock file '{0}' because atomic write is enabled.",
401
401
  this.resourceForError(resource)
402
402
  ))));
@@ -411,7 +411,7 @@ let FileService = class FileService extends Disposable {
411
411
  }
412
412
  if ((stat.type & FileType.Directory) !== 0) {
413
413
  throw ( (new FileOperationError(localize(
414
- 722,
414
+ 718,
415
415
  "Unable to write file '{0}' that is actually a directory",
416
416
  this.resourceForError(resource)
417
417
  ), 0 , options)));
@@ -421,7 +421,7 @@ let FileService = class FileService extends Disposable {
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(723, "File Modified Since"),
424
+ localize(719, "File Modified Since"),
425
425
  3 ,
426
426
  options
427
427
  )));
@@ -508,7 +508,7 @@ let FileService = class FileService extends Disposable {
508
508
  }
509
509
  restoreReadError(error, resource, options) {
510
510
  const message = ( localize(
511
- 724,
511
+ 720,
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
- 725,
577
+ 721,
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(726, "File not modified since"), stat, options)));
583
+ throw ( (new NotModifiedSinceFileOperationError(localize(722, "File not modified since"), stat, options)));
584
584
  }
585
585
  this.validateReadFileLimits(resource, stat.size, options);
586
586
  return stat;
@@ -588,7 +588,7 @@ 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
- 727,
591
+ 723,
592
592
  "Unable to read file '{0}' that is too large to open",
593
593
  this.resourceForError(resource)
594
594
  ), 7 , size, options)));
@@ -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
- 728,
713
+ 724,
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
- 729,
721
+ 725,
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,7 +729,7 @@ let FileService = class FileService extends Disposable {
729
729
  if (exists && !isSameResourceWithDifferentPathCase) {
730
730
  if (!overwrite) {
731
731
  throw ( (new FileOperationError(localize(
732
- 730,
732
+ 726,
733
733
  "Unable to move/copy '{0}' because target '{1}' already exists at destination.",
734
734
  this.resourceForError(source),
735
735
  this.resourceForError(target)
@@ -739,7 +739,7 @@ let FileService = class FileService extends Disposable {
739
739
  const { providerExtUri } = this.getExtUri(sourceProvider);
740
740
  if (providerExtUri.isEqualOrParent(source, target)) {
741
741
  throw ( (new Error(localize(
742
- 731,
742
+ 727,
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)
@@ -784,7 +784,7 @@ let FileService = class FileService extends Disposable {
784
784
  const useTrash = !!options?.useTrash;
785
785
  if (useTrash && !((provider.capabilities & 4096) )) {
786
786
  throw ( (new Error(localize(
787
- 732,
787
+ 728,
788
788
  "Unable to delete file '{0}' via trash because provider does not support it.",
789
789
  this.resourceForError(resource)
790
790
  ))));
@@ -792,14 +792,14 @@ let FileService = class FileService extends Disposable {
792
792
  const atomic = options?.atomic;
793
793
  if (atomic && !((provider.capabilities & 65536) )) {
794
794
  throw ( (new Error(localize(
795
- 733,
795
+ 729,
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
- 734,
802
+ 730,
803
803
  "Unable to atomically delete file '{0}' because using trash is enabled.",
804
804
  this.resourceForError(resource)
805
805
  ))));
@@ -815,7 +815,7 @@ let FileService = class FileService extends Disposable {
815
815
  }
816
816
  else {
817
817
  throw ( (new FileOperationError(localize(
818
- 735,
818
+ 731,
819
819
  "Unable to delete nonexistent file '{0}'",
820
820
  this.resourceForError(resource)
821
821
  ), 1 )));
@@ -825,7 +825,7 @@ let FileService = class FileService extends Disposable {
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
- 736,
828
+ 732,
829
829
  "Unable to delete non-empty folder '{0}'.",
830
830
  this.resourceForError(resource)
831
831
  ))));
@@ -1086,7 +1086,7 @@ let FileService = class FileService extends Disposable {
1086
1086
  throwIfFileSystemIsReadonly(provider, resource) {
1087
1087
  if (provider.capabilities & 2048 ) {
1088
1088
  throw ( (new FileOperationError(localize(
1089
- 737,
1089
+ 733,
1090
1090
  "Unable to modify read-only file '{0}'",
1091
1091
  this.resourceForError(resource)
1092
1092
  ), 6 )));
@@ -1096,7 +1096,7 @@ let FileService = class FileService extends Disposable {
1096
1096
  throwIfFileIsReadonly(resource, stat) {
1097
1097
  if ((stat.permissions ?? 0) & FilePermission.Readonly) {
1098
1098
  throw ( (new FileOperationError(localize(
1099
- 737,
1099
+ 733,
1100
1100
  "Unable to modify read-only file '{0}'",
1101
1101
  this.resourceForError(resource)
1102
1102
  ), 6 )));
@@ -61,7 +61,7 @@ let TextFileEditorModelManager = class TextFileEditorModelManager extends Dispos
61
61
  return {
62
62
  onSaveError(error, model) {
63
63
  notificationService.error(( localize(
64
- 9909,
64
+ 9982,
65
65
  "Failed to save '{0}': {1}",
66
66
  model.name,
67
67
  toErrorMessage(error, false)
@@ -1,42 +1,73 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { raceCancellation } from 'vscode/vscode/vs/base/common/async';
3
+ import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
3
4
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
5
+ import { IProgressService } from 'vscode/vscode/vs/platform/progress/common/progress.service';
4
6
  import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
5
- import { insert } from 'vscode/vscode/vs/base/common/arrays';
7
+ import { LinkedList } from 'vscode/vscode/vs/base/common/linkedList';
8
+ import { localize } from 'vscode/vscode/vs/nls';
9
+ import { NotificationPriority } from 'vscode/vscode/vs/platform/notification/common/notification';
10
+ import { isCancellationError, CancellationError } from 'vscode/vscode/vs/base/common/errors';
6
11
 
7
12
  let TextFileSaveParticipant = class TextFileSaveParticipant extends Disposable {
8
- constructor(logService) {
13
+ constructor(logService, progressService) {
9
14
  super();
10
15
  this.logService = logService;
11
- this.saveParticipants = [];
16
+ this.progressService = progressService;
17
+ this.saveParticipants = ( (new LinkedList()));
12
18
  }
13
19
  addSaveParticipant(participant) {
14
- const remove = insert(this.saveParticipants, participant);
20
+ const remove = this.saveParticipants.push(participant);
15
21
  return toDisposable(() => remove());
16
22
  }
17
23
  async participate(model, context, progress, token) {
24
+ const cts = ( (new CancellationTokenSource(token)));
18
25
  model.textEditorModel?.pushStackElement();
19
- for (const saveParticipant of this.saveParticipants) {
20
- if (token.isCancellationRequested || !model.textEditorModel ) {
21
- break;
26
+ progress.report({
27
+ message: ( localize(11518, "Running Code Actions and Formatters..."))
28
+ });
29
+ let bubbleCancel = false;
30
+ await this.progressService.withProgress({
31
+ priority: NotificationPriority.URGENT,
32
+ location: 15 ,
33
+ cancellable: ( localize(11519, "Skip")),
34
+ delay: model.isDirty() ? 5000 : 3000
35
+ }, async (progress) => {
36
+ for (const saveParticipant of this.saveParticipants) {
37
+ if (cts.token.isCancellationRequested || !model.textEditorModel ) {
38
+ break;
39
+ }
40
+ try {
41
+ const promise = saveParticipant.participate(model, context, progress, cts.token);
42
+ await raceCancellation(promise, cts.token);
43
+ }
44
+ catch (err) {
45
+ if (!isCancellationError(err)) {
46
+ this.logService.error(err);
47
+ }
48
+ else if (!cts.token.isCancellationRequested) {
49
+ cts.cancel();
50
+ bubbleCancel = true;
51
+ }
52
+ }
22
53
  }
23
- try {
24
- const promise = saveParticipant.participate(model, context, progress, token);
25
- await raceCancellation(promise, token);
26
- }
27
- catch (err) {
28
- this.logService.error(err);
29
- }
30
- }
54
+ }, () => {
55
+ cts.cancel();
56
+ });
31
57
  model.textEditorModel?.pushStackElement();
58
+ cts.dispose();
59
+ if (bubbleCancel) {
60
+ throw ( (new CancellationError()));
61
+ }
32
62
  }
33
63
  dispose() {
34
- this.saveParticipants.splice(0, this.saveParticipants.length);
64
+ this.saveParticipants.clear();
35
65
  super.dispose();
36
66
  }
37
67
  };
38
- TextFileSaveParticipant = ( __decorate([
39
- ( __param(0, ILogService))
40
- ], TextFileSaveParticipant));
68
+ TextFileSaveParticipant = ( (__decorate([
69
+ ( (__param(0, ILogService))),
70
+ ( (__param(1, IProgressService)))
71
+ ], TextFileSaveParticipant)));
41
72
 
42
73
  export { TextFileSaveParticipant };