@codingame/monaco-vscode-api 1.76.2 → 1.76.3-next.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.
Files changed (59) hide show
  1. package/README.md +2 -1
  2. package/dist/api.js +3 -860
  3. package/dist/{extHost.js → api2.js} +16555 -13467
  4. package/dist/async.js +107 -2
  5. package/dist/audioCue.js +105 -103
  6. package/dist/button.js +1 -1
  7. package/dist/cancellation.js +3 -0
  8. package/dist/configuration.js +7 -344
  9. package/dist/configuration2.js +339 -0
  10. package/dist/configurationRegistry.js +441 -0
  11. package/dist/contextkeys.js +211 -0
  12. package/dist/debug.d.ts +22 -0
  13. package/dist/debug.js +15842 -0
  14. package/dist/dialogs.js +855 -9
  15. package/dist/extensionResourceLoader.js +96 -0
  16. package/dist/extensions.d.ts +491 -0
  17. package/dist/extensions.js +70 -0
  18. package/dist/{tools.js → extensionsRegistry.js} +2 -30
  19. package/dist/files.js +1407 -334
  20. package/dist/iconv.js +43 -0
  21. package/dist/injection.js +1 -1
  22. package/dist/jschardet.js +7 -0
  23. package/dist/keybindings.d.ts +1 -485
  24. package/dist/keybindings.js +666 -679
  25. package/dist/labels.js +14 -0
  26. package/dist/languageConfiguration.d.ts +1 -2
  27. package/dist/languageConfiguration.js +9 -16
  28. package/dist/languageService.js +112 -8
  29. package/dist/languages.d.ts +1 -473
  30. package/dist/languages.js +2 -12
  31. package/dist/layout.js +4 -3
  32. package/dist/layoutService.js +1 -1
  33. package/dist/missing-services.js +4710 -74
  34. package/dist/modelEditor.d.ts +324 -2
  35. package/dist/modelEditor.js +15 -228
  36. package/dist/monaco.js +7 -72
  37. package/dist/notifications.js +75 -232
  38. package/dist/polyfill.js +10715 -2459
  39. package/dist/resources.js +197 -0
  40. package/dist/services.d.ts +924 -3
  41. package/dist/services.js +1 -2
  42. package/dist/services2.js +2436 -18
  43. package/dist/snippets.d.ts +1 -473
  44. package/dist/snippets.js +8 -867
  45. package/dist/snippetsService.js +868 -0
  46. package/dist/textFileEditorModel.js +2985 -0
  47. package/dist/textmate.d.ts +3 -475
  48. package/dist/textmate.js +19 -29
  49. package/dist/theme.d.ts +1 -3
  50. package/dist/theme.js +24 -70
  51. package/dist/tokenClassification.d.ts +1 -475
  52. package/dist/tokenClassification.js +11 -37
  53. package/dist/tokenClassificationRegistry.js +8 -4
  54. package/dist/variableResolver.js +1711 -0
  55. package/dist/workbenchThemeService.js +1 -1
  56. package/dist/workspaceContext.js +1 -3
  57. package/package.json +27 -12
  58. package/dist/contextkey.js +0 -419
  59. package/dist/dialog.web.contribution.js +0 -945
package/dist/files.js CHANGED
@@ -1,370 +1,269 @@
1
- import { _ as __decorate, a as __param, E as Emitter } from './contextkey.js';
2
- import { m as isReadableStream, o as peekStream, q as peekReadable, r as bufferToReadable, s as streamToBuffer, t as consumeStream, u as transform, v as isReadableBufferedStream, x as listenStream, y as bufferedStreamToBuffer, z as readableToBuffer, B as newWriteableBufferStream, C as newWriteableStream } from './polyfill.js';
3
- import { u as unsupported } from './missing-services.js';
4
- import { bt as getRemoteServerRootPath, bu as supportsTelemetry, bv as getTelemetryLevel, bj as DEFAULT_EXTENSION, F as Disposable$1, c as CancellationTokenSource } from './extHost.js';
5
- import { c as IFileService, h as IProductService, S as Services, t as createFileSystemProviderError, u as FileChangesEvent, v as FileOperationError, w as hasOpenReadWriteCloseCapability, x as hasReadWriteCapability, y as hasFileReadStreamCapability, z as toFileSystemProviderErrorCode, B as FileSystemProviderErrorCode, C as ensureFileSystemProviderError, F as FileType, a as FilePermission, D as etag, E as FileOperationEvent, G as toFileOperationResult, H as ETAG_DISABLED, J as hasFileAtomicReadCapability, N as NotModifiedSinceFileOperationError, T as TooLargeFileOperationError, K as hasFileFolderCopyCapability, L as hasFileCloneCapability, M as FileSystemProviderError } from './services2.js';
1
+ import { _ as __decorate, E as Emitter, a as __param, T as TextFileOperationError, K as toBufferOrReadable, l as ITextFileService, I as IEditorService, n as IFileService, q as IWorkingCopyFileService, j as IUriIdentityService, o as IWorkbenchEnvironmentService, r as IPathService, e as IProductService, L as stringToSnapshot, m as mark, M as FileChangesEvent, v as FileOperationError, O as hasOpenReadWriteCloseCapability, P as hasReadWriteCapability, Q as hasFileReadStreamCapability, x as toFileSystemProviderErrorCode, F as FileSystemProviderErrorCode, R as ensureFileSystemProviderError, h as FileType, i as FilePermission, U as etag, V as FileOperationEvent, W as toFileOperationResult, X as ETAG_DISABLED, Y as hasFileAtomicReadCapability, Z as NotModifiedSinceFileOperationError, $ as TooLargeFileOperationError, a0 as hasFileFolderCopyCapability, a1 as hasFileCloneCapability, a2 as createFileSystemProviderError, a3 as FileSystemProviderError } from './services2.js';
2
+ import { y as bufferToReadable, z as bufferToStream, B as consumeStream, C as insert, D as isReadableStream, E as peekStream, F as peekReadable, G as streamToBuffer, H as transform, J as isReadableBufferedStream, K as listenStream, L as bufferedStreamToBuffer, M as readableToBuffer, O as newWriteableBufferStream, Q as newWriteableStream } from './polyfill.js';
3
+ import { b$ as SaveSourceRegistry, c0 as IWorkingCopyBackupService, I as IWorkingCopyService, bP as ILanguageDetectionService, c1 as IUntitledTextEditorService, bL as ILifecycleService, c2 as IFileDialogService, c3 as IFilesConfigurationService, c4 as IElevatedFileService, c5 as IDecorationsService, u as unsupported, D as Disposable$1 } from './missing-services.js';
4
+ import { C as CancellationTokenSource } from './cancellation.js';
6
5
  import { VSBuffer } from 'monaco-editor/esm/vs/base/common/buffer.js';
7
- import { canceled, ErrorNoTelemetry } from 'monaco-editor/esm/vs/base/common/errors.js';
6
+ import { onUnexpectedError, canceled, ErrorNoTelemetry } from 'monaco-editor/esm/vs/base/common/errors.js';
8
7
  import { localize } from 'monaco-editor/esm/vs/nls.js';
9
8
  import { R as ResourceQueue } from './async.js';
10
- import { Disposable, toDisposable, dispose, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
11
- import { Promises } from 'monaco-editor/esm/vs/base/common/async.js';
9
+ import { Disposable, dispose, toDisposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
10
+ import { Promises, raceCancellation } from 'monaco-editor/esm/vs/base/common/async.js';
12
11
  import { Iterable } from 'monaco-editor/esm/vs/base/common/iterator.js';
13
- import { basename, dirname, isAbsolutePath, extUri, extUriIgnorePathCase } from 'monaco-editor/esm/vs/base/common/resources.js';
12
+ import { isEqual, basename, dirname, joinPath, extname as extname$1, isAbsolutePath, extUri, extUriIgnorePathCase } from 'monaco-editor/esm/vs/base/common/resources.js';
14
13
  import { TernarySearchTree } from 'monaco-editor/esm/vs/base/common/ternarySearchTree.js';
15
- import { coalesce } from 'monaco-editor/esm/vs/base/common/arrays.js';
14
+ import { firstOrDefault, coalesce } from 'monaco-editor/esm/vs/base/common/arrays.js';
16
15
  import { hash } from 'monaco-editor/esm/vs/base/common/hash.js';
17
16
  import { CancellationToken } from 'monaco-editor/esm/vs/base/common/cancellation.js';
18
- import { RemoteAuthorities, Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
17
+ import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
19
18
  import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
20
- import { generateUuid } from 'monaco-editor/esm/vs/base/common/uuid.js';
21
- import { Lazy } from 'monaco-editor/esm/vs/base/common/lazy.js';
22
- import { LRUCachedFunction } from 'monaco-editor/esm/vs/base/common/cache.js';
23
- import { createDecorator } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
19
+ import { I as IExtensionResourceLoaderService, A as AbstractExtensionResourceLoaderService } from './extensionResourceLoader.js';
20
+ import { B as BaseTextEditorModel, N as NO_TYPE_ID, U as UTF8, c as createTextBufferFactoryFromStream, t as toEncodeReadable, a as toDecodeStream, b as UTF16be, d as UTF16le, e as UTF8_with_bom, f as encodingExists, T as TextFileEditorModel } from './textFileEditorModel.js';
21
+ import { withNullAsUndefined, assertIsDefined } from 'monaco-editor/esm/vs/base/common/types.js';
22
+ import { getCharContainingOffset } from 'monaco-editor/esm/vs/base/common/strings.js';
23
+ import { ensureValidWordDefinition } from 'monaco-editor/esm/vs/editor/common/core/wordHelper.js';
24
+ import { ILanguageService } from 'monaco-editor/esm/vs/editor/common/languages/language.js';
25
+ import { IModelService } from 'monaco-editor/esm/vs/editor/common/services/model.js';
26
+ import { ITextResourceConfigurationService } from 'monaco-editor/esm/vs/editor/common/services/textResourceConfiguration.js';
27
+ import { ILabelService } from 'monaco-editor/esm/vs/platform/label/common/label.js';
28
+ import { IAccessibilityService } from 'monaco-editor/esm/vs/platform/accessibility/common/accessibility.js';
29
+ import { IProgressService } from 'monaco-editor/esm/vs/platform/progress/common/progress.js';
30
+ import { ResourceMap } from 'monaco-editor/esm/vs/base/common/map.js';
31
+ import { toErrorMessage } from 'monaco-editor/esm/vs/base/common/errorMessage.js';
32
+ import { createTextBufferFactoryFromSnapshot } from 'monaco-editor/esm/vs/editor/common/model/textModel.js';
33
+ import { PLAINTEXT_LANGUAGE_ID, PLAINTEXT_EXTENSION } from 'monaco-editor/esm/vs/editor/common/languages/modesRegistry.js';
24
34
  import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
25
- import { isWeb } from 'monaco-editor/esm/vs/base/common/platform.js';
26
- import './dialog.web.contribution.js';
35
+ import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
36
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
37
+ import { INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
38
+ import { listErrorForeground } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
39
+ import { t as toLocalResource } from './resources.js';
40
+ import { Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
41
+ import { extname } from 'monaco-editor/esm/vs/base/common/path.js';
42
+ import { IDialogService } from 'monaco-editor/esm/vs/platform/dialogs/common/dialogs.js';
43
+ import { ICodeEditorService } from 'monaco-editor/esm/vs/editor/browser/services/codeEditorService.js';
44
+ import { WORKSPACE_EXTENSION, IWorkspaceContextService } from 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
27
45
  import { registerSingleton } from 'monaco-editor/esm/vs/platform/instantiation/common/extensions.js';
28
46
  import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
29
47
  import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
30
48
  import { IEnvironmentService } from 'monaco-editor/esm/vs/platform/environment/common/environment.js';
31
49
  import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
32
- import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
33
- var _a;
34
- const _format2Regexp = /{([^}]+)}/g;
35
- function format2(template, values) {
36
- return template.replace(_format2Regexp, (match, group) => (values[group] ?? match));
37
- }
38
- class AmbiguousCharacters {
39
- static getInstance(locales) {
40
- return AmbiguousCharacters.cache.get(Array.from(locales));
41
- }
42
- static getLocales() {
43
- return AmbiguousCharacters._locales.value;
44
- }
45
- constructor(confusableDictionary) {
46
- this.confusableDictionary = confusableDictionary;
47
- }
48
- isAmbiguous(codePoint) {
49
- return this.confusableDictionary.has(codePoint);
50
- }
51
- getPrimaryConfusable(codePoint) {
52
- return this.confusableDictionary.get(codePoint);
53
- }
54
- getConfusableCodePoints() {
55
- return (
56
- (new Set( (this.confusableDictionary.keys())))
57
- );
58
- }
59
- }
60
- _a = AmbiguousCharacters;
61
- AmbiguousCharacters.ambiguousCharacterData = ( (new Lazy(() => {
62
- return JSON.parse('{\"_common\":[8232,32,8233,32,5760,32,8192,32,8193,32,8194,32,8195,32,8196,32,8197,32,8198,32,8200,32,8201,32,8202,32,8287,32,8199,32,8239,32,2042,95,65101,95,65102,95,65103,95,8208,45,8209,45,8210,45,65112,45,1748,45,8259,45,727,45,8722,45,10134,45,11450,45,1549,44,1643,44,8218,44,184,44,42233,44,894,59,2307,58,2691,58,1417,58,1795,58,1796,58,5868,58,65072,58,6147,58,6153,58,8282,58,1475,58,760,58,42889,58,8758,58,720,58,42237,58,451,33,11601,33,660,63,577,63,2429,63,5038,63,42731,63,119149,46,8228,46,1793,46,1794,46,42510,46,68176,46,1632,46,1776,46,42232,46,1373,96,65287,96,8219,96,8242,96,1370,96,1523,96,8175,96,65344,96,900,96,8189,96,8125,96,8127,96,8190,96,697,96,884,96,712,96,714,96,715,96,756,96,699,96,701,96,700,96,702,96,42892,96,1497,96,2036,96,2037,96,5194,96,5836,96,94033,96,94034,96,65339,91,10088,40,10098,40,12308,40,64830,40,65341,93,10089,41,10099,41,12309,41,64831,41,10100,123,119060,123,10101,125,65342,94,8270,42,1645,42,8727,42,66335,42,5941,47,8257,47,8725,47,8260,47,9585,47,10187,47,10744,47,119354,47,12755,47,12339,47,11462,47,20031,47,12035,47,65340,92,65128,92,8726,92,10189,92,10741,92,10745,92,119311,92,119355,92,12756,92,20022,92,12034,92,42872,38,708,94,710,94,5869,43,10133,43,66203,43,8249,60,10094,60,706,60,119350,60,5176,60,5810,60,5120,61,11840,61,12448,61,42239,61,8250,62,10095,62,707,62,119351,62,5171,62,94015,62,8275,126,732,126,8128,126,8764,126,65372,124,65293,45,120784,50,120794,50,120804,50,120814,50,120824,50,130034,50,42842,50,423,50,1000,50,42564,50,5311,50,42735,50,119302,51,120785,51,120795,51,120805,51,120815,51,120825,51,130035,51,42923,51,540,51,439,51,42858,51,11468,51,1248,51,94011,51,71882,51,120786,52,120796,52,120806,52,120816,52,120826,52,130036,52,5070,52,71855,52,120787,53,120797,53,120807,53,120817,53,120827,53,130037,53,444,53,71867,53,120788,54,120798,54,120808,54,120818,54,120828,54,130038,54,11474,54,5102,54,71893,54,119314,55,120789,55,120799,55,120809,55,120819,55,120829,55,130039,55,66770,55,71878,55,2819,56,2538,56,2666,56,125131,56,120790,56,120800,56,120810,56,120820,56,120830,56,130040,56,547,56,546,56,66330,56,2663,57,2920,57,2541,57,3437,57,120791,57,120801,57,120811,57,120821,57,120831,57,130041,57,42862,57,11466,57,71884,57,71852,57,71894,57,9082,97,65345,97,119834,97,119886,97,119938,97,119990,97,120042,97,120094,97,120146,97,120198,97,120250,97,120302,97,120354,97,120406,97,120458,97,593,97,945,97,120514,97,120572,97,120630,97,120688,97,120746,97,65313,65,119808,65,119860,65,119912,65,119964,65,120016,65,120068,65,120120,65,120172,65,120224,65,120276,65,120328,65,120380,65,120432,65,913,65,120488,65,120546,65,120604,65,120662,65,120720,65,5034,65,5573,65,42222,65,94016,65,66208,65,119835,98,119887,98,119939,98,119991,98,120043,98,120095,98,120147,98,120199,98,120251,98,120303,98,120355,98,120407,98,120459,98,388,98,5071,98,5234,98,5551,98,65314,66,8492,66,119809,66,119861,66,119913,66,120017,66,120069,66,120121,66,120173,66,120225,66,120277,66,120329,66,120381,66,120433,66,42932,66,914,66,120489,66,120547,66,120605,66,120663,66,120721,66,5108,66,5623,66,42192,66,66178,66,66209,66,66305,66,65347,99,8573,99,119836,99,119888,99,119940,99,119992,99,120044,99,120096,99,120148,99,120200,99,120252,99,120304,99,120356,99,120408,99,120460,99,7428,99,1010,99,11429,99,43951,99,66621,99,128844,67,71922,67,71913,67,65315,67,8557,67,8450,67,8493,67,119810,67,119862,67,119914,67,119966,67,120018,67,120174,67,120226,67,120278,67,120330,67,120382,67,120434,67,1017,67,11428,67,5087,67,42202,67,66210,67,66306,67,66581,67,66844,67,8574,100,8518,100,119837,100,119889,100,119941,100,119993,100,120045,100,120097,100,120149,100,120201,100,120253,100,120305,100,120357,100,120409,100,120461,100,1281,100,5095,100,5231,100,42194,100,8558,68,8517,68,119811,68,119863,68,119915,68,119967,68,120019,68,120071,68,120123,68,120175,68,120227,68,120279,68,120331,68,120383,68,120435,68,5024,68,5598,68,5610,68,42195,68,8494,101,65349,101,8495,101,8519,101,119838,101,119890,101,119942,101,120046,101,120098,101,120150,101,120202,101,120254,101,120306,101,120358,101,120410,101,120462,101,43826,101,1213,101,8959,69,65317,69,8496,69,119812,69,119864,69,119916,69,120020,69,120072,69,120124,69,120176,69,120228,69,120280,69,120332,69,120384,69,120436,69,917,69,120492,69,120550,69,120608,69,120666,69,120724,69,11577,69,5036,69,42224,69,71846,69,71854,69,66182,69,119839,102,119891,102,119943,102,119995,102,120047,102,120099,102,120151,102,120203,102,120255,102,120307,102,120359,102,120411,102,120463,102,43829,102,42905,102,383,102,7837,102,1412,102,119315,70,8497,70,119813,70,119865,70,119917,70,120021,70,120073,70,120125,70,120177,70,120229,70,120281,70,120333,70,120385,70,120437,70,42904,70,988,70,120778,70,5556,70,42205,70,71874,70,71842,70,66183,70,66213,70,66853,70,65351,103,8458,103,119840,103,119892,103,119944,103,120048,103,120100,103,120152,103,120204,103,120256,103,120308,103,120360,103,120412,103,120464,103,609,103,7555,103,397,103,1409,103,119814,71,119866,71,119918,71,119970,71,120022,71,120074,71,120126,71,120178,71,120230,71,120282,71,120334,71,120386,71,120438,71,1292,71,5056,71,5107,71,42198,71,65352,104,8462,104,119841,104,119945,104,119997,104,120049,104,120101,104,120153,104,120205,104,120257,104,120309,104,120361,104,120413,104,120465,104,1211,104,1392,104,5058,104,65320,72,8459,72,8460,72,8461,72,119815,72,119867,72,119919,72,120023,72,120179,72,120231,72,120283,72,120335,72,120387,72,120439,72,919,72,120494,72,120552,72,120610,72,120668,72,120726,72,11406,72,5051,72,5500,72,42215,72,66255,72,731,105,9075,105,65353,105,8560,105,8505,105,8520,105,119842,105,119894,105,119946,105,119998,105,120050,105,120102,105,120154,105,120206,105,120258,105,120310,105,120362,105,120414,105,120466,105,120484,105,618,105,617,105,953,105,8126,105,890,105,120522,105,120580,105,120638,105,120696,105,120754,105,1110,105,42567,105,1231,105,43893,105,5029,105,71875,105,65354,106,8521,106,119843,106,119895,106,119947,106,119999,106,120051,106,120103,106,120155,106,120207,106,120259,106,120311,106,120363,106,120415,106,120467,106,1011,106,1112,106,65322,74,119817,74,119869,74,119921,74,119973,74,120025,74,120077,74,120129,74,120181,74,120233,74,120285,74,120337,74,120389,74,120441,74,42930,74,895,74,1032,74,5035,74,5261,74,42201,74,119844,107,119896,107,119948,107,120000,107,120052,107,120104,107,120156,107,120208,107,120260,107,120312,107,120364,107,120416,107,120468,107,8490,75,65323,75,119818,75,119870,75,119922,75,119974,75,120026,75,120078,75,120130,75,120182,75,120234,75,120286,75,120338,75,120390,75,120442,75,922,75,120497,75,120555,75,120613,75,120671,75,120729,75,11412,75,5094,75,5845,75,42199,75,66840,75,1472,108,8739,73,9213,73,65512,73,1633,108,1777,73,66336,108,125127,108,120783,73,120793,73,120803,73,120813,73,120823,73,130033,73,65321,73,8544,73,8464,73,8465,73,119816,73,119868,73,119920,73,120024,73,120128,73,120180,73,120232,73,120284,73,120336,73,120388,73,120440,73,65356,108,8572,73,8467,108,119845,108,119897,108,119949,108,120001,108,120053,108,120105,73,120157,73,120209,73,120261,73,120313,73,120365,73,120417,73,120469,73,448,73,120496,73,120554,73,120612,73,120670,73,120728,73,11410,73,1030,73,1216,73,1493,108,1503,108,1575,108,126464,108,126592,108,65166,108,65165,108,1994,108,11599,73,5825,73,42226,73,93992,73,66186,124,66313,124,119338,76,8556,76,8466,76,119819,76,119871,76,119923,76,120027,76,120079,76,120131,76,120183,76,120235,76,120287,76,120339,76,120391,76,120443,76,11472,76,5086,76,5290,76,42209,76,93974,76,71843,76,71858,76,66587,76,66854,76,65325,77,8559,77,8499,77,119820,77,119872,77,119924,77,120028,77,120080,77,120132,77,120184,77,120236,77,120288,77,120340,77,120392,77,120444,77,924,77,120499,77,120557,77,120615,77,120673,77,120731,77,1018,77,11416,77,5047,77,5616,77,5846,77,42207,77,66224,77,66321,77,119847,110,119899,110,119951,110,120003,110,120055,110,120107,110,120159,110,120211,110,120263,110,120315,110,120367,110,120419,110,120471,110,1400,110,1404,110,65326,78,8469,78,119821,78,119873,78,119925,78,119977,78,120029,78,120081,78,120185,78,120237,78,120289,78,120341,78,120393,78,120445,78,925,78,120500,78,120558,78,120616,78,120674,78,120732,78,11418,78,42208,78,66835,78,3074,111,3202,111,3330,111,3458,111,2406,111,2662,111,2790,111,3046,111,3174,111,3302,111,3430,111,3664,111,3792,111,4160,111,1637,111,1781,111,65359,111,8500,111,119848,111,119900,111,119952,111,120056,111,120108,111,120160,111,120212,111,120264,111,120316,111,120368,111,120420,111,120472,111,7439,111,7441,111,43837,111,959,111,120528,111,120586,111,120644,111,120702,111,120760,111,963,111,120532,111,120590,111,120648,111,120706,111,120764,111,11423,111,4351,111,1413,111,1505,111,1607,111,126500,111,126564,111,126596,111,65259,111,65260,111,65258,111,65257,111,1726,111,64428,111,64429,111,64427,111,64426,111,1729,111,64424,111,64425,111,64423,111,64422,111,1749,111,3360,111,4125,111,66794,111,71880,111,71895,111,66604,111,1984,79,2534,79,2918,79,12295,79,70864,79,71904,79,120782,79,120792,79,120802,79,120812,79,120822,79,130032,79,65327,79,119822,79,119874,79,119926,79,119978,79,120030,79,120082,79,120134,79,120186,79,120238,79,120290,79,120342,79,120394,79,120446,79,927,79,120502,79,120560,79,120618,79,120676,79,120734,79,11422,79,1365,79,11604,79,4816,79,2848,79,66754,79,42227,79,71861,79,66194,79,66219,79,66564,79,66838,79,9076,112,65360,112,119849,112,119901,112,119953,112,120005,112,120057,112,120109,112,120161,112,120213,112,120265,112,120317,112,120369,112,120421,112,120473,112,961,112,120530,112,120544,112,120588,112,120602,112,120646,112,120660,112,120704,112,120718,112,120762,112,120776,112,11427,112,65328,80,8473,80,119823,80,119875,80,119927,80,119979,80,120031,80,120083,80,120187,80,120239,80,120291,80,120343,80,120395,80,120447,80,929,80,120504,80,120562,80,120620,80,120678,80,120736,80,11426,80,5090,80,5229,80,42193,80,66197,80,119850,113,119902,113,119954,113,120006,113,120058,113,120110,113,120162,113,120214,113,120266,113,120318,113,120370,113,120422,113,120474,113,1307,113,1379,113,1382,113,8474,81,119824,81,119876,81,119928,81,119980,81,120032,81,120084,81,120188,81,120240,81,120292,81,120344,81,120396,81,120448,81,11605,81,119851,114,119903,114,119955,114,120007,114,120059,114,120111,114,120163,114,120215,114,120267,114,120319,114,120371,114,120423,114,120475,114,43847,114,43848,114,7462,114,11397,114,43905,114,119318,82,8475,82,8476,82,8477,82,119825,82,119877,82,119929,82,120033,82,120189,82,120241,82,120293,82,120345,82,120397,82,120449,82,422,82,5025,82,5074,82,66740,82,5511,82,42211,82,94005,82,65363,115,119852,115,119904,115,119956,115,120008,115,120060,115,120112,115,120164,115,120216,115,120268,115,120320,115,120372,115,120424,115,120476,115,42801,115,445,115,1109,115,43946,115,71873,115,66632,115,65331,83,119826,83,119878,83,119930,83,119982,83,120034,83,120086,83,120138,83,120190,83,120242,83,120294,83,120346,83,120398,83,120450,83,1029,83,1359,83,5077,83,5082,83,42210,83,94010,83,66198,83,66592,83,119853,116,119905,116,119957,116,120009,116,120061,116,120113,116,120165,116,120217,116,120269,116,120321,116,120373,116,120425,116,120477,116,8868,84,10201,84,128872,84,65332,84,119827,84,119879,84,119931,84,119983,84,120035,84,120087,84,120139,84,120191,84,120243,84,120295,84,120347,84,120399,84,120451,84,932,84,120507,84,120565,84,120623,84,120681,84,120739,84,11430,84,5026,84,42196,84,93962,84,71868,84,66199,84,66225,84,66325,84,119854,117,119906,117,119958,117,120010,117,120062,117,120114,117,120166,117,120218,117,120270,117,120322,117,120374,117,120426,117,120478,117,42911,117,7452,117,43854,117,43858,117,651,117,965,117,120534,117,120592,117,120650,117,120708,117,120766,117,1405,117,66806,117,71896,117,8746,85,8899,85,119828,85,119880,85,119932,85,119984,85,120036,85,120088,85,120140,85,120192,85,120244,85,120296,85,120348,85,120400,85,120452,85,1357,85,4608,85,66766,85,5196,85,42228,85,94018,85,71864,85,8744,118,8897,118,65366,118,8564,118,119855,118,119907,118,119959,118,120011,118,120063,118,120115,118,120167,118,120219,118,120271,118,120323,118,120375,118,120427,118,120479,118,7456,118,957,118,120526,118,120584,118,120642,118,120700,118,120758,118,1141,118,1496,118,71430,118,43945,118,71872,118,119309,86,1639,86,1783,86,8548,86,119829,86,119881,86,119933,86,119985,86,120037,86,120089,86,120141,86,120193,86,120245,86,120297,86,120349,86,120401,86,120453,86,1140,86,11576,86,5081,86,5167,86,42719,86,42214,86,93960,86,71840,86,66845,86,623,119,119856,119,119908,119,119960,119,120012,119,120064,119,120116,119,120168,119,120220,119,120272,119,120324,119,120376,119,120428,119,120480,119,7457,119,1121,119,1309,119,1377,119,71434,119,71438,119,71439,119,43907,119,71919,87,71910,87,119830,87,119882,87,119934,87,119986,87,120038,87,120090,87,120142,87,120194,87,120246,87,120298,87,120350,87,120402,87,120454,87,1308,87,5043,87,5076,87,42218,87,5742,120,10539,120,10540,120,10799,120,65368,120,8569,120,119857,120,119909,120,119961,120,120013,120,120065,120,120117,120,120169,120,120221,120,120273,120,120325,120,120377,120,120429,120,120481,120,5441,120,5501,120,5741,88,9587,88,66338,88,71916,88,65336,88,8553,88,119831,88,119883,88,119935,88,119987,88,120039,88,120091,88,120143,88,120195,88,120247,88,120299,88,120351,88,120403,88,120455,88,42931,88,935,88,120510,88,120568,88,120626,88,120684,88,120742,88,11436,88,11613,88,5815,88,42219,88,66192,88,66228,88,66327,88,66855,88,611,121,7564,121,65369,121,119858,121,119910,121,119962,121,120014,121,120066,121,120118,121,120170,121,120222,121,120274,121,120326,121,120378,121,120430,121,120482,121,655,121,7935,121,43866,121,947,121,8509,121,120516,121,120574,121,120632,121,120690,121,120748,121,1199,121,4327,121,71900,121,65337,89,119832,89,119884,89,119936,89,119988,89,120040,89,120092,89,120144,89,120196,89,120248,89,120300,89,120352,89,120404,89,120456,89,933,89,978,89,120508,89,120566,89,120624,89,120682,89,120740,89,11432,89,1198,89,5033,89,5053,89,42220,89,94019,89,71844,89,66226,89,119859,122,119911,122,119963,122,120015,122,120067,122,120119,122,120171,122,120223,122,120275,122,120327,122,120379,122,120431,122,120483,122,7458,122,43923,122,71876,122,66293,90,71909,90,65338,90,8484,90,8488,90,119833,90,119885,90,119937,90,119989,90,120041,90,120197,90,120249,90,120301,90,120353,90,120405,90,120457,90,918,90,120493,90,120551,90,120609,90,120667,90,120725,90,5059,90,42204,90,71849,90,65282,34,65284,36,65285,37,65286,38,65290,42,65291,43,65294,46,65295,47,65296,48,65297,49,65298,50,65299,51,65300,52,65301,53,65302,54,65303,55,65304,56,65305,57,65308,60,65309,61,65310,62,65312,64,65316,68,65318,70,65319,71,65324,76,65329,81,65330,82,65333,85,65334,86,65335,87,65343,95,65346,98,65348,100,65350,102,65355,107,65357,109,65358,110,65361,113,65362,114,65364,116,65365,117,65367,119,65370,122,65371,123,65373,125],\"_default\":[160,32,8211,45,65374,126,65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65283,35,65288,40,65289,41,65292,44,65307,59,65311,63],\"cs\":[65374,126,65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,1093,120,1061,88,1091,121,1059,89,65283,35,65288,40,65289,41,65292,44,65307,59,65311,63],\"de\":[65374,126,65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,1093,120,1061,88,1091,121,1059,89,65283,35,65288,40,65289,41,65292,44,65307,59,65311,63],\"es\":[8211,45,65374,126,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65283,35,65288,40,65289,41,65292,44,65307,59,65311,63],\"fr\":[65374,126,65306,58,65281,33,8216,96,8245,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65283,35,65288,40,65289,41,65292,44,65307,59,65311,63],\"it\":[160,32,8211,45,65374,126,65306,58,65281,33,8216,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65283,35,65288,40,65289,41,65292,44,65307,59,65311,63],\"ja\":[8211,45,65306,58,65281,33,8216,96,8217,96,8245,96,180,96,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65283,35,65292,44,65307,59],\"ko\":[8211,45,65374,126,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65283,35,65288,40,65289,41,65292,44,65307,59,65311,63],\"pl\":[65374,126,65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65283,35,65288,40,65289,41,65292,44,65307,59,65311,63],\"pt-BR\":[65374,126,65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65283,35,65288,40,65289,41,65292,44,65307,59,65311,63],\"qps-ploc\":[160,32,8211,45,65374,126,65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65283,35,65288,40,65289,41,65292,44,65307,59,65311,63],\"ru\":[65374,126,65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,305,105,921,73,1009,112,215,120,65283,35,65288,40,65289,41,65292,44,65307,59,65311,63],\"tr\":[160,32,8211,45,65374,126,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65283,35,65288,40,65289,41,65292,44,65307,59,65311,63],\"zh-hans\":[65374,126,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65288,40,65289,41],\"zh-hant\":[8211,45,65374,126,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,73,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89,65283,35,65307,59]}');
63
- })));
64
- AmbiguousCharacters.cache = ( (new LRUCachedFunction((locales) => {
65
- function arrayToMap(arr) {
66
- const result = ( (new Map()));
67
- for (let i = 0; i < arr.length; i += 2) {
68
- result.set(arr[i], arr[i + 1]);
69
- }
70
- return result;
71
- }
72
- function mergeMaps(map1, map2) {
73
- const result = ( (new Map(map1)));
74
- for (const [key, value] of map2) {
75
- result.set(key, value);
76
- }
77
- return result;
78
- }
79
- function intersectMaps(map1, map2) {
80
- if (!map1) {
81
- return map2;
50
+ let UntitledTextEditorModel = class UntitledTextEditorModel extends BaseTextEditorModel {
51
+ get name() {
52
+ if (this.configuredLabelFormat === 'content' && !this.hasAssociatedFilePath && this.cachedModelFirstLineWords) {
53
+ return this.cachedModelFirstLineWords;
54
+ }
55
+ return this.labelService.getUriBasenameLabel(this.resource);
56
+ }
57
+ constructor(resource, hasAssociatedFilePath, initialValue, preferredLanguageId, preferredEncoding, languageService, modelService, workingCopyBackupService, textResourceConfigurationService, workingCopyService, textFileService, labelService, editorService, languageDetectionService, accessibilityService) {
58
+ super(modelService, languageService, languageDetectionService, accessibilityService);
59
+ this.resource = resource;
60
+ this.hasAssociatedFilePath = hasAssociatedFilePath;
61
+ this.initialValue = initialValue;
62
+ this.preferredLanguageId = preferredLanguageId;
63
+ this.preferredEncoding = preferredEncoding;
64
+ this.workingCopyBackupService = workingCopyBackupService;
65
+ this.textResourceConfigurationService = textResourceConfigurationService;
66
+ this.workingCopyService = workingCopyService;
67
+ this.textFileService = textFileService;
68
+ this.labelService = labelService;
69
+ this.editorService = editorService;
70
+ this._onDidChangeContent = this._register(( (new Emitter())));
71
+ this.onDidChangeContent = this._onDidChangeContent.event;
72
+ this._onDidChangeName = this._register(( (new Emitter())));
73
+ this.onDidChangeName = this._onDidChangeName.event;
74
+ this._onDidChangeDirty = this._register(( (new Emitter())));
75
+ this.onDidChangeDirty = this._onDidChangeDirty.event;
76
+ this._onDidChangeEncoding = this._register(( (new Emitter())));
77
+ this.onDidChangeEncoding = this._onDidChangeEncoding.event;
78
+ this._onDidSave = this._register(( (new Emitter())));
79
+ this.onDidSave = this._onDidSave.event;
80
+ this._onDidRevert = this._register(( (new Emitter())));
81
+ this.onDidRevert = this._onDidRevert.event;
82
+ this.typeId = NO_TYPE_ID;
83
+ this.capabilities = 2 ;
84
+ this.configuredLabelFormat = 'content';
85
+ this.cachedModelFirstLineWords = undefined;
86
+ this.dirty = this.hasAssociatedFilePath || !!this.initialValue;
87
+ this._register(this.workingCopyService.registerWorkingCopy(this));
88
+ if (preferredLanguageId) {
89
+ this.setLanguageId(preferredLanguageId);
90
+ }
91
+ this.onConfigurationChange(undefined, false);
92
+ this.registerListeners();
93
+ }
94
+ registerListeners() {
95
+ this._register(this.textResourceConfigurationService.onDidChangeConfiguration(e => this.onConfigurationChange(e, true)));
96
+ }
97
+ onConfigurationChange(e, fromEvent) {
98
+ if (!e || e.affectsConfiguration(this.resource, 'files.encoding')) {
99
+ const configuredEncoding = this.textResourceConfigurationService.getValue(this.resource, 'files.encoding');
100
+ if (this.configuredEncoding !== configuredEncoding && typeof configuredEncoding === 'string') {
101
+ this.configuredEncoding = configuredEncoding;
102
+ if (fromEvent && !this.preferredEncoding) {
103
+ this._onDidChangeEncoding.fire();
104
+ }
105
+ }
82
106
  }
83
- const result = ( (new Map()));
84
- for (const [key, value] of map1) {
85
- if (map2.has(key)) {
86
- result.set(key, value);
107
+ if (!e || e.affectsConfiguration(this.resource, 'workbench.editor.untitled.labelFormat')) {
108
+ const configuredLabelFormat = this.textResourceConfigurationService.getValue(this.resource, 'workbench.editor.untitled.labelFormat');
109
+ if (this.configuredLabelFormat !== configuredLabelFormat && (configuredLabelFormat === 'content' || configuredLabelFormat === 'name')) {
110
+ this.configuredLabelFormat = configuredLabelFormat;
111
+ if (fromEvent) {
112
+ this._onDidChangeName.fire();
113
+ }
87
114
  }
88
115
  }
89
- return result;
90
- }
91
- const data = _a.ambiguousCharacterData.value;
92
- let filteredLocales = locales.filter((l) => !l.startsWith('_') && l in data);
93
- if (filteredLocales.length === 0) {
94
- filteredLocales = ['_default'];
95
- }
96
- let languageSpecificMap = undefined;
97
- for (const locale of filteredLocales) {
98
- const map = arrayToMap(data[locale]);
99
- languageSpecificMap = intersectMaps(languageSpecificMap, map);
100
- }
101
- const commonMap = arrayToMap(data['_common']);
102
- const map = mergeMaps(commonMap, languageSpecificMap);
103
- return (
104
- (new AmbiguousCharacters(map))
105
- );
106
- })));
107
- AmbiguousCharacters._locales = ( (new Lazy(
108
- () => ( (Object.keys(AmbiguousCharacters.ambiguousCharacterData.value))).filter((k) => !k.startsWith('_'))
109
- )));
110
- const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
111
- function isUUID(value) {
112
- return _UUIDPattern.test(value);
113
- }
114
- async function getServiceMachineId(environmentService, fileService, storageService) {
115
- let uuid = storageService ? storageService.get('storage.serviceMachineId', -1 ) || null : null;
116
- if (uuid) {
117
- return uuid;
118
116
  }
119
- try {
120
- const contents = await fileService.readFile(environmentService.serviceMachineIdResource);
121
- const value = ( (contents.value.toString()));
122
- uuid = isUUID(value) ? value : null;
123
- }
124
- catch (e) {
125
- uuid = null;
126
- }
127
- if (!uuid) {
128
- uuid = generateUuid();
129
- try {
130
- await fileService.writeFile(environmentService.serviceMachineIdResource, VSBuffer.fromString(uuid));
131
- }
132
- catch (error) {
117
+ setLanguageId(languageId, source) {
118
+ const actualLanguage = languageId === UntitledTextEditorModel.ACTIVE_EDITOR_LANGUAGE_ID
119
+ ? this.editorService.activeTextEditorLanguageId
120
+ : languageId;
121
+ this.preferredLanguageId = actualLanguage;
122
+ if (actualLanguage) {
123
+ super.setLanguageId(actualLanguage, source);
133
124
  }
134
125
  }
135
- storageService?.store('storage.serviceMachineId', uuid, -1 , 1 );
136
- return uuid;
137
- }
138
- const WEB_EXTENSION_RESOURCE_END_POINT = 'web-extension-resource';
139
- const IExtensionResourceLoaderService = ( (createDecorator('extensionResourceLoaderService')));
140
- class AbstractExtensionResourceLoaderService {
141
- constructor(_fileService, _storageService, _productService, _environmentService, _configurationService) {
142
- this._fileService = _fileService;
143
- this._storageService = _storageService;
144
- this._productService = _productService;
145
- this._environmentService = _environmentService;
146
- this._configurationService = _configurationService;
147
- this._webExtensionResourceEndPoint = `${getRemoteServerRootPath(_productService)}/${WEB_EXTENSION_RESOURCE_END_POINT}/`;
148
- if (_productService.extensionsGallery) {
149
- this._extensionGalleryResourceUrlTemplate = _productService.extensionsGallery.resourceUrlTemplate;
150
- this._extensionGalleryAuthority = this._extensionGalleryResourceUrlTemplate ? this._getExtensionGalleryAuthority(( (URI.parse(this._extensionGalleryResourceUrlTemplate)))) : undefined;
151
- }
152
- }
153
- get supportsExtensionGalleryResources() {
154
- return this._extensionGalleryResourceUrlTemplate !== undefined;
155
- }
156
- getExtensionGalleryResourceURL(galleryExtension, path) {
157
- if (this._extensionGalleryResourceUrlTemplate) {
158
- const uri = ( (URI.parse(
159
- format2(this._extensionGalleryResourceUrlTemplate, { publisher: galleryExtension.publisher, name: galleryExtension.name, version: galleryExtension.version, path: 'extension' })
160
- )));
161
- return this._isWebExtensionResourceEndPoint(uri) ? uri.with({ scheme: RemoteAuthorities.getPreferredWebSchema() }) : uri;
126
+ getLanguageId() {
127
+ if (this.textEditorModel) {
128
+ return this.textEditorModel.getLanguageId();
162
129
  }
163
- return undefined;
130
+ return this.preferredLanguageId;
164
131
  }
165
- isExtensionGalleryResource(uri) {
166
- return this._extensionGalleryAuthority && this._extensionGalleryAuthority === this._getExtensionGalleryAuthority(uri);
132
+ getEncoding() {
133
+ return this.preferredEncoding || this.configuredEncoding;
167
134
  }
168
- async getExtensionGalleryRequestHeaders() {
169
- const headers = {
170
- 'X-Client-Name': `${this._productService.applicationName}${isWeb ? '-web' : ''}`,
171
- 'X-Client-Version': this._productService.version
172
- };
173
- if (supportsTelemetry(this._productService, this._environmentService) && getTelemetryLevel(this._configurationService) === 3 ) {
174
- headers['X-Machine-Id'] = await this._getServiceMachineId();
135
+ async setEncoding(encoding) {
136
+ const oldEncoding = this.getEncoding();
137
+ this.preferredEncoding = encoding;
138
+ if (oldEncoding !== this.preferredEncoding) {
139
+ this._onDidChangeEncoding.fire();
175
140
  }
176
- if (this._productService.commit) {
177
- headers['X-Client-Commit'] = this._productService.commit;
178
- }
179
- return headers;
180
141
  }
181
- _getServiceMachineId() {
182
- if (!this._serviceMachineIdPromise) {
183
- this._serviceMachineIdPromise = getServiceMachineId(this._environmentService, this._fileService, this._storageService);
184
- }
185
- return this._serviceMachineIdPromise;
142
+ isDirty() {
143
+ return this.dirty;
186
144
  }
187
- _getExtensionGalleryAuthority(uri) {
188
- if (this._isWebExtensionResourceEndPoint(uri)) {
189
- return uri.authority;
145
+ setDirty(dirty) {
146
+ if (this.dirty === dirty) {
147
+ return;
190
148
  }
191
- const index = uri.authority.indexOf('.');
192
- return index !== -1 ? uri.authority.substring(index + 1) : undefined;
193
- }
194
- _isWebExtensionResourceEndPoint(uri) {
195
- return uri.path.startsWith(this._webExtensionResourceEndPoint);
196
- }
197
- }
198
- let File$1 = class File {
199
- constructor(name) {
200
- this.type = FileType.File;
201
- this.ctime = Date.now();
202
- this.mtime = Date.now();
203
- this.size = 0;
204
- this.name = name;
205
- }
206
- };
207
- class Directory {
208
- constructor(name) {
209
- this.type = FileType.Directory;
210
- this.ctime = Date.now();
211
- this.mtime = Date.now();
212
- this.size = 0;
213
- this.name = name;
214
- this.entries = ( (new Map()));
215
- }
216
- }
217
- class InMemoryFileSystemProvider extends Disposable {
218
- constructor() {
219
- super(...arguments);
220
- this._onDidChangeCapabilities = this._register(( (new Emitter())));
221
- this.onDidChangeCapabilities = this._onDidChangeCapabilities.event;
222
- this._capabilities = 2 | 1024 ;
223
- this.root = ( (new Directory('')));
224
- this._onDidChangeFile = this._register(( (new Emitter())));
225
- this.onDidChangeFile = this._onDidChangeFile.event;
226
- this._bufferedChanges = [];
149
+ this.dirty = dirty;
150
+ this._onDidChangeDirty.fire();
227
151
  }
228
- get capabilities() { return this._capabilities; }
229
- setReadOnly(readonly) {
230
- const isReadonly = !!((this._capabilities & 2048) );
231
- if (readonly !== isReadonly) {
232
- this._capabilities = readonly ? 2048 | 1024 | 2
233
- : 2 | 1024 ;
234
- this._onDidChangeCapabilities.fire();
152
+ async save(options) {
153
+ const target = await this.textFileService.save(this.resource, options);
154
+ if (target) {
155
+ this._onDidSave.fire({ reason: options?.reason, source: options?.source });
235
156
  }
157
+ return !!target;
236
158
  }
237
- async stat(resource) {
238
- return this._lookup(resource, false);
239
- }
240
- async readdir(resource) {
241
- const entry = this._lookupAsDirectory(resource, false);
242
- const result = [];
243
- entry.entries.forEach((child, name) => result.push([name, child.type]));
244
- return result;
159
+ async revert() {
160
+ this.setDirty(false);
161
+ this._onDidRevert.fire();
162
+ this.dispose();
245
163
  }
246
- async readFile(resource) {
247
- const data = this._lookupAsFile(resource, false).data;
248
- if (data) {
249
- return data;
164
+ async backup(token) {
165
+ let content = undefined;
166
+ if (this.isResolved()) {
167
+ content = await this.textFileService.getEncodedReadable(this.resource, withNullAsUndefined(this.createSnapshot()), { encoding: UTF8 });
250
168
  }
251
- throw createFileSystemProviderError('file not found', FileSystemProviderErrorCode.FileNotFound);
252
- }
253
- async writeFile(resource, content, opts) {
254
- const basename$1 = basename(resource);
255
- const parent = this._lookupParentDirectory(resource);
256
- let entry = parent.entries.get(basename$1);
257
- if (entry instanceof Directory) {
258
- throw createFileSystemProviderError('file is directory', FileSystemProviderErrorCode.FileIsADirectory);
169
+ else if (typeof this.initialValue === 'string') {
170
+ content = bufferToReadable(VSBuffer.fromString(this.initialValue));
259
171
  }
260
- if (!entry && !opts.create) {
261
- throw createFileSystemProviderError('file not found', FileSystemProviderErrorCode.FileNotFound);
172
+ return { content };
173
+ }
174
+ async resolve() {
175
+ let createdUntitledModel = false;
176
+ let hasBackup = false;
177
+ if (!this.textEditorModel) {
178
+ let untitledContents;
179
+ const backup = await this.workingCopyBackupService.resolve(this);
180
+ if (backup) {
181
+ untitledContents = backup.value;
182
+ hasBackup = true;
183
+ }
184
+ else {
185
+ untitledContents = bufferToStream(VSBuffer.fromString(this.initialValue || ''));
186
+ }
187
+ const untitledContentsFactory = await createTextBufferFactoryFromStream(await this.textFileService.getDecodedStream(this.resource, untitledContents, { encoding: UTF8 }));
188
+ this.createTextEditorModel(untitledContentsFactory, this.resource, this.preferredLanguageId);
189
+ createdUntitledModel = true;
262
190
  }
263
- if (entry && opts.create && !opts.overwrite) {
264
- throw createFileSystemProviderError('file exists already', FileSystemProviderErrorCode.FileExists);
191
+ else {
192
+ this.updateTextEditorModel(undefined, this.preferredLanguageId);
265
193
  }
266
- if (!entry) {
267
- entry = ( (new File$1(basename$1)));
268
- parent.entries.set(basename$1, entry);
269
- this._fireSoon({ type: 1 , resource });
194
+ const textEditorModel = assertIsDefined(this.textEditorModel);
195
+ this.installModelListeners(textEditorModel);
196
+ if (createdUntitledModel) {
197
+ if (hasBackup || this.initialValue) {
198
+ this.updateNameFromFirstLine(textEditorModel);
199
+ }
200
+ this.setDirty(this.hasAssociatedFilePath || !!hasBackup || !!this.initialValue);
201
+ if (hasBackup || this.initialValue) {
202
+ this._onDidChangeContent.fire();
203
+ }
270
204
  }
271
- entry.mtime = Date.now();
272
- entry.size = content.byteLength;
273
- entry.data = content;
274
- this._fireSoon({ type: 0 , resource });
205
+ return super.resolve();
275
206
  }
276
- async rename(from, to, opts) {
277
- if (!opts.overwrite && this._lookup(to, true)) {
278
- throw createFileSystemProviderError('file exists already', FileSystemProviderErrorCode.FileExists);
279
- }
280
- const entry = this._lookup(from, false);
281
- const oldParent = this._lookupParentDirectory(from);
282
- const newParent = this._lookupParentDirectory(to);
283
- const newName = basename(to);
284
- oldParent.entries.delete(entry.name);
285
- entry.name = newName;
286
- newParent.entries.set(newName, entry);
287
- this._fireSoon({ type: 2 , resource: from }, { type: 1 , resource: to });
207
+ installModelListeners(model) {
208
+ this._register(model.onDidChangeContent(e => this.onModelContentChanged(model, e)));
209
+ this._register(model.onDidChangeLanguage(() => this.onConfigurationChange(undefined, true)));
210
+ super.installModelListeners(model);
288
211
  }
289
- async delete(resource, opts) {
290
- const dirname$1 = dirname(resource);
291
- const basename$1 = basename(resource);
292
- const parent = this._lookupAsDirectory(dirname$1, false);
293
- if (parent.entries.has(basename$1)) {
294
- parent.entries.delete(basename$1);
295
- parent.mtime = Date.now();
296
- parent.size -= 1;
297
- this._fireSoon({ type: 0 , resource: dirname$1 }, { resource, type: 2 });
212
+ onModelContentChanged(textEditorModel, e) {
213
+ if (!this.hasAssociatedFilePath && textEditorModel.getLineCount() === 1 && textEditorModel.getLineContent(1) === '') {
214
+ this.setDirty(false);
298
215
  }
299
- }
300
- async mkdir(resource) {
301
- if (this._lookup(resource, true)) {
302
- throw createFileSystemProviderError('file exists already', FileSystemProviderErrorCode.FileExists);
216
+ else {
217
+ this.setDirty(true);
303
218
  }
304
- const basename$1 = basename(resource);
305
- const dirname$1 = dirname(resource);
306
- const parent = this._lookupAsDirectory(dirname$1, false);
307
- const entry = ( (new Directory(basename$1)));
308
- parent.entries.set(entry.name, entry);
309
- parent.mtime = Date.now();
310
- parent.size += 1;
311
- this._fireSoon({ type: 0 , resource: dirname$1 }, { type: 1 , resource });
312
- }
313
- _lookup(uri, silent) {
314
- const parts = uri.path.split('/');
315
- let entry = this.root;
316
- for (const part of parts) {
317
- if (!part) {
318
- continue;
319
- }
320
- let child;
321
- if (entry instanceof Directory) {
322
- child = entry.entries.get(part);
323
- }
324
- if (!child) {
325
- if (!silent) {
326
- throw createFileSystemProviderError('file not found', FileSystemProviderErrorCode.FileNotFound);
327
- }
328
- else {
329
- return undefined;
330
- }
331
- }
332
- entry = child;
219
+ if (e.changes.some(change => (change.range.startLineNumber === 1 || change.range.endLineNumber === 1) && change.range.startColumn <= UntitledTextEditorModel.FIRST_LINE_NAME_CANDIDATE_MAX_LENGTH)) {
220
+ this.updateNameFromFirstLine(textEditorModel);
333
221
  }
334
- return entry;
222
+ this._onDidChangeContent.fire();
223
+ this.autoDetectLanguage();
335
224
  }
336
- _lookupAsDirectory(uri, silent) {
337
- const entry = this._lookup(uri, silent);
338
- if (entry instanceof Directory) {
339
- return entry;
225
+ updateNameFromFirstLine(textEditorModel) {
226
+ if (this.hasAssociatedFilePath) {
227
+ return;
340
228
  }
341
- throw createFileSystemProviderError('file not a directory', FileSystemProviderErrorCode.FileNotADirectory);
342
- }
343
- _lookupAsFile(uri, silent) {
344
- const entry = this._lookup(uri, silent);
345
- if (entry instanceof File$1) {
346
- return entry;
229
+ let modelFirstWordsCandidate = undefined;
230
+ let firstLineText = textEditorModel
231
+ .getValueInRange({
232
+ startLineNumber: 1,
233
+ endLineNumber: 1,
234
+ startColumn: 1,
235
+ endColumn: UntitledTextEditorModel.FIRST_LINE_NAME_CANDIDATE_MAX_LENGTH + 1
236
+ })
237
+ .trim().replace(/\s+/g, ' ');
238
+ firstLineText = firstLineText.substr(0, getCharContainingOffset(
239
+ firstLineText, UntitledTextEditorModel.FIRST_LINE_NAME_MAX_LENGTH)[0]);
240
+ if (firstLineText && ensureValidWordDefinition().exec(firstLineText)) {
241
+ modelFirstWordsCandidate = firstLineText;
347
242
  }
348
- throw createFileSystemProviderError('file is a directory', FileSystemProviderErrorCode.FileIsADirectory);
349
- }
350
- _lookupParentDirectory(uri) {
351
- const dirname$1 = dirname(uri);
352
- return this._lookupAsDirectory(dirname$1, false);
353
- }
354
- watch(resource, opts) {
355
- return Disposable.None;
356
- }
357
- _fireSoon(...changes) {
358
- this._bufferedChanges.push(...changes);
359
- if (this._fireSoonHandle) {
360
- clearTimeout(this._fireSoonHandle);
243
+ if (modelFirstWordsCandidate !== this.cachedModelFirstLineWords) {
244
+ this.cachedModelFirstLineWords = modelFirstWordsCandidate;
245
+ this._onDidChangeName.fire();
361
246
  }
362
- this._fireSoonHandle = setTimeout(() => {
363
- this._onDidChangeFile.fire(this._bufferedChanges);
364
- this._bufferedChanges.length = 0;
365
- }, 5);
366
247
  }
367
- }
248
+ isReadonly() {
249
+ return false;
250
+ }
251
+ };
252
+ UntitledTextEditorModel.FIRST_LINE_NAME_MAX_LENGTH = 40;
253
+ UntitledTextEditorModel.FIRST_LINE_NAME_CANDIDATE_MAX_LENGTH = UntitledTextEditorModel.FIRST_LINE_NAME_MAX_LENGTH * 10;
254
+ UntitledTextEditorModel.ACTIVE_EDITOR_LANGUAGE_ID = '${activeEditorLanguage}';
255
+ UntitledTextEditorModel = ( (__decorate([
256
+ ( (__param(5, ILanguageService))),
257
+ ( (__param(6, IModelService))),
258
+ ( (__param(7, IWorkingCopyBackupService))),
259
+ ( (__param(8, ITextResourceConfigurationService))),
260
+ ( (__param(9, IWorkingCopyService))),
261
+ ( (__param(10, ITextFileService))),
262
+ ( (__param(11, ILabelService))),
263
+ ( (__param(12, IEditorService))),
264
+ ( (__param(13, ILanguageDetectionService))),
265
+ ( (__param(14, IAccessibilityService)))
266
+ ], UntitledTextEditorModel)));
368
267
  async function readFileIntoStream(provider, resource, target, transformer, options, token) {
369
268
  let error = undefined;
370
269
  try {
@@ -465,6 +364,7 @@ let FileService = class FileService extends Disposable {
465
364
  if (this.provider.has(scheme)) {
466
365
  throw new Error(`A filesystem provider for the scheme '${scheme}' is already registered.`);
467
366
  }
367
+ mark(`code/registerFilesystem/${scheme}`);
468
368
  const providerDisposables = ( (new DisposableStore()));
469
369
  this.provider.set(scheme, provider);
470
370
  this._onDidChangeFileSystemProviderRegistrations.fire({ added: true, scheme, provider });
@@ -507,7 +407,12 @@ let FileService = class FileService extends Disposable {
507
407
  return !!(provider && (provider.capabilities & capability));
508
408
  }
509
409
  listCapabilities() {
510
- return Iterable.map(this.provider, ([scheme, provider]) => ({ scheme, capabilities: provider.capabilities }));
410
+ return (
411
+ (Iterable.map(
412
+ this.provider,
413
+ ([scheme, provider]) => ({ scheme, capabilities: provider.capabilities })
414
+ ))
415
+ );
511
416
  }
512
417
  async withProvider(resource) {
513
418
  if (!isAbsolutePath(resource)) {
@@ -594,7 +499,7 @@ let FileService = class FileService extends Disposable {
594
499
  if (fileStat.isDirectory && recurse(fileStat, siblings)) {
595
500
  try {
596
501
  const entries = await provider.readdir(resource);
597
- const resolvedEntries = await Promises.settled(entries.map(async ([name, type]) => {
502
+ const resolvedEntries = await Promises.settled(( (entries.map(async ([name, type]) => {
598
503
  try {
599
504
  const childResource = providerExtUri.joinPath(resource, name);
600
505
  const childStat = resolveMetadata ? await provider.stat(childResource) : { type };
@@ -604,7 +509,7 @@ let FileService = class FileService extends Disposable {
604
509
  this.logService.trace(error);
605
510
  return null;
606
511
  }
607
- }));
512
+ }))));
608
513
  fileStat.children = coalesce(resolvedEntries);
609
514
  }
610
515
  catch (error) {
@@ -616,7 +521,7 @@ let FileService = class FileService extends Disposable {
616
521
  return fileStat;
617
522
  }
618
523
  async resolveAll(toResolve) {
619
- return Promises.settled(toResolve.map(async (entry) => {
524
+ return Promises.settled(( (toResolve.map(async (entry) => {
620
525
  try {
621
526
  return { stat: await this.doResolveFile(entry.resource, entry.options), success: true };
622
527
  }
@@ -624,7 +529,7 @@ let FileService = class FileService extends Disposable {
624
529
  this.logService.trace(error);
625
530
  return { stat: undefined, success: false };
626
531
  }
627
- }));
532
+ }))));
628
533
  }
629
534
  async stat(resource) {
630
535
  const provider = await this.withProvider(resource);
@@ -980,7 +885,7 @@ let FileService = class FileService extends Disposable {
980
885
  async doCopyFolder(sourceProvider, sourceFolder, targetProvider, targetFolder) {
981
886
  await targetProvider.mkdir(targetFolder);
982
887
  if (Array.isArray(sourceFolder.children)) {
983
- await Promises.settled(sourceFolder.children.map(async (sourceChild) => {
888
+ await Promises.settled(( (sourceFolder.children.map(async (sourceChild) => {
984
889
  const targetChild = this.getExtUri(targetProvider).providerExtUri.joinPath(targetFolder, sourceChild.name);
985
890
  if (sourceChild.isDirectory) {
986
891
  return this.doCopyFolder(sourceProvider, await this.resolve(sourceChild.resource), targetProvider, targetChild);
@@ -988,7 +893,7 @@ let FileService = class FileService extends Disposable {
988
893
  else {
989
894
  return this.doCopyFile(sourceProvider, sourceChild.resource, targetProvider, targetChild);
990
895
  }
991
- }));
896
+ }))));
992
897
  }
993
898
  }
994
899
  async doValidateMoveCopy(sourceProvider, source, targetProvider, target, mode, overwrite) {
@@ -1348,6 +1253,1174 @@ let FileService = class FileService extends Disposable {
1348
1253
  FileService = ( (__decorate([
1349
1254
  ( (__param(0, ILogService)))
1350
1255
  ], FileService)));
1256
+ let File$1 = class File {
1257
+ constructor(name) {
1258
+ this.type = FileType.File;
1259
+ this.ctime = Date.now();
1260
+ this.mtime = Date.now();
1261
+ this.size = 0;
1262
+ this.name = name;
1263
+ }
1264
+ };
1265
+ class Directory {
1266
+ constructor(name) {
1267
+ this.type = FileType.Directory;
1268
+ this.ctime = Date.now();
1269
+ this.mtime = Date.now();
1270
+ this.size = 0;
1271
+ this.name = name;
1272
+ this.entries = ( (new Map()));
1273
+ }
1274
+ }
1275
+ class InMemoryFileSystemProvider extends Disposable {
1276
+ constructor() {
1277
+ super(...arguments);
1278
+ this._onDidChangeCapabilities = this._register(( (new Emitter())));
1279
+ this.onDidChangeCapabilities = this._onDidChangeCapabilities.event;
1280
+ this._capabilities = 2 | 1024 ;
1281
+ this.root = ( (new Directory('')));
1282
+ this._onDidChangeFile = this._register(( (new Emitter())));
1283
+ this.onDidChangeFile = this._onDidChangeFile.event;
1284
+ this._bufferedChanges = [];
1285
+ }
1286
+ get capabilities() { return this._capabilities; }
1287
+ setReadOnly(readonly) {
1288
+ const isReadonly = !!((this._capabilities & 2048) );
1289
+ if (readonly !== isReadonly) {
1290
+ this._capabilities = readonly ? 2048 | 1024 | 2
1291
+ : 2 | 1024 ;
1292
+ this._onDidChangeCapabilities.fire();
1293
+ }
1294
+ }
1295
+ async stat(resource) {
1296
+ return this._lookup(resource, false);
1297
+ }
1298
+ async readdir(resource) {
1299
+ const entry = this._lookupAsDirectory(resource, false);
1300
+ const result = [];
1301
+ entry.entries.forEach((child, name) => result.push([name, child.type]));
1302
+ return result;
1303
+ }
1304
+ async readFile(resource) {
1305
+ const data = this._lookupAsFile(resource, false).data;
1306
+ if (data) {
1307
+ return data;
1308
+ }
1309
+ throw createFileSystemProviderError('file not found', FileSystemProviderErrorCode.FileNotFound);
1310
+ }
1311
+ async writeFile(resource, content, opts) {
1312
+ const basename$1 = basename(resource);
1313
+ const parent = this._lookupParentDirectory(resource);
1314
+ let entry = parent.entries.get(basename$1);
1315
+ if (entry instanceof Directory) {
1316
+ throw createFileSystemProviderError('file is directory', FileSystemProviderErrorCode.FileIsADirectory);
1317
+ }
1318
+ if (!entry && !opts.create) {
1319
+ throw createFileSystemProviderError('file not found', FileSystemProviderErrorCode.FileNotFound);
1320
+ }
1321
+ if (entry && opts.create && !opts.overwrite) {
1322
+ throw createFileSystemProviderError('file exists already', FileSystemProviderErrorCode.FileExists);
1323
+ }
1324
+ if (!entry) {
1325
+ entry = ( (new File$1(basename$1)));
1326
+ parent.entries.set(basename$1, entry);
1327
+ this._fireSoon({ type: 1 , resource });
1328
+ }
1329
+ entry.mtime = Date.now();
1330
+ entry.size = content.byteLength;
1331
+ entry.data = content;
1332
+ this._fireSoon({ type: 0 , resource });
1333
+ }
1334
+ async rename(from, to, opts) {
1335
+ if (!opts.overwrite && this._lookup(to, true)) {
1336
+ throw createFileSystemProviderError('file exists already', FileSystemProviderErrorCode.FileExists);
1337
+ }
1338
+ const entry = this._lookup(from, false);
1339
+ const oldParent = this._lookupParentDirectory(from);
1340
+ const newParent = this._lookupParentDirectory(to);
1341
+ const newName = basename(to);
1342
+ oldParent.entries.delete(entry.name);
1343
+ entry.name = newName;
1344
+ newParent.entries.set(newName, entry);
1345
+ this._fireSoon({ type: 2 , resource: from }, { type: 1 , resource: to });
1346
+ }
1347
+ async delete(resource, opts) {
1348
+ const dirname$1 = dirname(resource);
1349
+ const basename$1 = basename(resource);
1350
+ const parent = this._lookupAsDirectory(dirname$1, false);
1351
+ if (parent.entries.has(basename$1)) {
1352
+ parent.entries.delete(basename$1);
1353
+ parent.mtime = Date.now();
1354
+ parent.size -= 1;
1355
+ this._fireSoon({ type: 0 , resource: dirname$1 }, { resource, type: 2 });
1356
+ }
1357
+ }
1358
+ async mkdir(resource) {
1359
+ if (this._lookup(resource, true)) {
1360
+ throw createFileSystemProviderError('file exists already', FileSystemProviderErrorCode.FileExists);
1361
+ }
1362
+ const basename$1 = basename(resource);
1363
+ const dirname$1 = dirname(resource);
1364
+ const parent = this._lookupAsDirectory(dirname$1, false);
1365
+ const entry = ( (new Directory(basename$1)));
1366
+ parent.entries.set(entry.name, entry);
1367
+ parent.mtime = Date.now();
1368
+ parent.size += 1;
1369
+ this._fireSoon({ type: 0 , resource: dirname$1 }, { type: 1 , resource });
1370
+ }
1371
+ _lookup(uri, silent) {
1372
+ const parts = uri.path.split('/');
1373
+ let entry = this.root;
1374
+ for (const part of parts) {
1375
+ if (!part) {
1376
+ continue;
1377
+ }
1378
+ let child;
1379
+ if (entry instanceof Directory) {
1380
+ child = entry.entries.get(part);
1381
+ }
1382
+ if (!child) {
1383
+ if (!silent) {
1384
+ throw createFileSystemProviderError('file not found', FileSystemProviderErrorCode.FileNotFound);
1385
+ }
1386
+ else {
1387
+ return undefined;
1388
+ }
1389
+ }
1390
+ entry = child;
1391
+ }
1392
+ return entry;
1393
+ }
1394
+ _lookupAsDirectory(uri, silent) {
1395
+ const entry = this._lookup(uri, silent);
1396
+ if (entry instanceof Directory) {
1397
+ return entry;
1398
+ }
1399
+ throw createFileSystemProviderError('file not a directory', FileSystemProviderErrorCode.FileNotADirectory);
1400
+ }
1401
+ _lookupAsFile(uri, silent) {
1402
+ const entry = this._lookup(uri, silent);
1403
+ if (entry instanceof File$1) {
1404
+ return entry;
1405
+ }
1406
+ throw createFileSystemProviderError('file is a directory', FileSystemProviderErrorCode.FileIsADirectory);
1407
+ }
1408
+ _lookupParentDirectory(uri) {
1409
+ const dirname$1 = dirname(uri);
1410
+ return this._lookupAsDirectory(dirname$1, false);
1411
+ }
1412
+ watch(resource, opts) {
1413
+ return Disposable.None;
1414
+ }
1415
+ _fireSoon(...changes) {
1416
+ this._bufferedChanges.push(...changes);
1417
+ if (this._fireSoonHandle) {
1418
+ clearTimeout(this._fireSoonHandle);
1419
+ }
1420
+ this._fireSoonHandle = setTimeout(() => {
1421
+ this._onDidChangeFile.fire(this._bufferedChanges);
1422
+ this._bufferedChanges.length = 0;
1423
+ }, 5);
1424
+ }
1425
+ }
1426
+ let TextFileSaveParticipant = class TextFileSaveParticipant extends Disposable {
1427
+ constructor(progressService, logService) {
1428
+ super();
1429
+ this.progressService = progressService;
1430
+ this.logService = logService;
1431
+ this.saveParticipants = [];
1432
+ }
1433
+ addSaveParticipant(participant) {
1434
+ const remove = insert(this.saveParticipants, participant);
1435
+ return toDisposable(() => remove());
1436
+ }
1437
+ participate(model, context, token) {
1438
+ const cts = ( (new CancellationTokenSource(token)));
1439
+ return this.progressService.withProgress({
1440
+ title: ( (localize('saveParticipants', "Saving '{0}'", model.name))),
1441
+ location: 15 ,
1442
+ cancellable: true,
1443
+ delay: model.isDirty() ? 3000 : 5000
1444
+ }, async (progress) => {
1445
+ model.textEditorModel?.pushStackElement();
1446
+ for (const saveParticipant of this.saveParticipants) {
1447
+ if (cts.token.isCancellationRequested || !model.textEditorModel ) {
1448
+ break;
1449
+ }
1450
+ try {
1451
+ const promise = saveParticipant.participate(model, context, progress, cts.token);
1452
+ await raceCancellation(promise, cts.token);
1453
+ }
1454
+ catch (err) {
1455
+ this.logService.error(err);
1456
+ }
1457
+ }
1458
+ model.textEditorModel?.pushStackElement();
1459
+ }, () => {
1460
+ cts.dispose(true);
1461
+ });
1462
+ }
1463
+ dispose() {
1464
+ this.saveParticipants.splice(0, this.saveParticipants.length);
1465
+ }
1466
+ };
1467
+ TextFileSaveParticipant = ( (__decorate([
1468
+ ( (__param(0, IProgressService))),
1469
+ ( (__param(1, ILogService)))
1470
+ ], TextFileSaveParticipant)));
1471
+ let TextFileEditorModelManager = class TextFileEditorModelManager extends Disposable {
1472
+ get models() {
1473
+ return [...( (this.mapResourceToModel.values()))];
1474
+ }
1475
+ constructor(instantiationService, fileService, notificationService, workingCopyFileService, uriIdentityService) {
1476
+ super();
1477
+ this.instantiationService = instantiationService;
1478
+ this.fileService = fileService;
1479
+ this.notificationService = notificationService;
1480
+ this.workingCopyFileService = workingCopyFileService;
1481
+ this.uriIdentityService = uriIdentityService;
1482
+ this._onDidCreate = this._register(( (new Emitter())));
1483
+ this.onDidCreate = this._onDidCreate.event;
1484
+ this._onDidResolve = this._register(( (new Emitter())));
1485
+ this.onDidResolve = this._onDidResolve.event;
1486
+ this._onDidRemove = this._register(( (new Emitter())));
1487
+ this.onDidRemove = this._onDidRemove.event;
1488
+ this._onDidChangeDirty = this._register(( (new Emitter())));
1489
+ this.onDidChangeDirty = this._onDidChangeDirty.event;
1490
+ this._onDidChangeReadonly = this._register(( (new Emitter())));
1491
+ this.onDidChangeReadonly = this._onDidChangeReadonly.event;
1492
+ this._onDidChangeOrphaned = this._register(( (new Emitter())));
1493
+ this.onDidChangeOrphaned = this._onDidChangeOrphaned.event;
1494
+ this._onDidSaveError = this._register(( (new Emitter())));
1495
+ this.onDidSaveError = this._onDidSaveError.event;
1496
+ this._onDidSave = this._register(( (new Emitter())));
1497
+ this.onDidSave = this._onDidSave.event;
1498
+ this._onDidRevert = this._register(( (new Emitter())));
1499
+ this.onDidRevert = this._onDidRevert.event;
1500
+ this._onDidChangeEncoding = this._register(( (new Emitter())));
1501
+ this.onDidChangeEncoding = this._onDidChangeEncoding.event;
1502
+ this.mapResourceToModel = ( (new ResourceMap()));
1503
+ this.mapResourceToModelListeners = ( (new ResourceMap()));
1504
+ this.mapResourceToDisposeListener = ( (new ResourceMap()));
1505
+ this.mapResourceToPendingModelResolvers = ( (new ResourceMap()));
1506
+ this.modelResolveQueue = this._register(( (new ResourceQueue())));
1507
+ this.saveErrorHandler = (() => {
1508
+ const notificationService = this.notificationService;
1509
+ return {
1510
+ onSaveError(error, model) {
1511
+ notificationService.error(( (localize(
1512
+ { key: 'genericSaveError', comment: ['{0} is the resource that failed to save and {1} the error message'] },
1513
+ "Failed to save '{0}': {1}",
1514
+ model.name,
1515
+ toErrorMessage(error, false)
1516
+ ))));
1517
+ }
1518
+ };
1519
+ })();
1520
+ this.mapCorrelationIdToModelsToRestore = ( (new Map()));
1521
+ this.saveParticipants = this._register(this.instantiationService.createInstance(TextFileSaveParticipant));
1522
+ this.registerListeners();
1523
+ }
1524
+ registerListeners() {
1525
+ this._register(this.fileService.onDidFilesChange(e => this.onDidFilesChange(e)));
1526
+ this._register(this.fileService.onDidChangeFileSystemProviderCapabilities(e => this.onDidChangeFileSystemProviderCapabilities(e)));
1527
+ this._register(this.fileService.onDidChangeFileSystemProviderRegistrations(e => this.onDidChangeFileSystemProviderRegistrations(e)));
1528
+ this._register(this.workingCopyFileService.onWillRunWorkingCopyFileOperation(e => this.onWillRunWorkingCopyFileOperation(e)));
1529
+ this._register(this.workingCopyFileService.onDidFailWorkingCopyFileOperation(e => this.onDidFailWorkingCopyFileOperation(e)));
1530
+ this._register(this.workingCopyFileService.onDidRunWorkingCopyFileOperation(e => this.onDidRunWorkingCopyFileOperation(e)));
1531
+ }
1532
+ onDidFilesChange(e) {
1533
+ for (const model of this.models) {
1534
+ if (model.isDirty()) {
1535
+ continue;
1536
+ }
1537
+ if (e.contains(model.resource, 0 , 1 )) {
1538
+ this.queueModelReload(model);
1539
+ }
1540
+ }
1541
+ }
1542
+ onDidChangeFileSystemProviderCapabilities(e) {
1543
+ this.queueModelReloads(e.scheme);
1544
+ }
1545
+ onDidChangeFileSystemProviderRegistrations(e) {
1546
+ if (!e.added) {
1547
+ return;
1548
+ }
1549
+ this.queueModelReloads(e.scheme);
1550
+ }
1551
+ queueModelReloads(scheme) {
1552
+ for (const model of this.models) {
1553
+ if (model.isDirty()) {
1554
+ continue;
1555
+ }
1556
+ if (scheme === model.resource.scheme) {
1557
+ this.queueModelReload(model);
1558
+ }
1559
+ }
1560
+ }
1561
+ queueModelReload(model) {
1562
+ const queue = this.modelResolveQueue.queueFor(model.resource);
1563
+ if (queue.size <= 1) {
1564
+ queue.queue(async () => {
1565
+ try {
1566
+ await this.reload(model);
1567
+ }
1568
+ catch (error) {
1569
+ onUnexpectedError(error);
1570
+ }
1571
+ });
1572
+ }
1573
+ }
1574
+ onWillRunWorkingCopyFileOperation(e) {
1575
+ if (e.operation === 2 || e.operation === 3 ) {
1576
+ const modelsToRestore = [];
1577
+ for (const { source, target } of e.files) {
1578
+ if (source) {
1579
+ if (this.uriIdentityService.extUri.isEqual(source, target)) {
1580
+ continue;
1581
+ }
1582
+ const sourceModels = [];
1583
+ for (const model of this.models) {
1584
+ if (this.uriIdentityService.extUri.isEqualOrParent(model.resource, source)) {
1585
+ sourceModels.push(model);
1586
+ }
1587
+ }
1588
+ for (const sourceModel of sourceModels) {
1589
+ const sourceModelResource = sourceModel.resource;
1590
+ let targetModelResource;
1591
+ if (this.uriIdentityService.extUri.isEqual(sourceModelResource, source)) {
1592
+ targetModelResource = target;
1593
+ }
1594
+ else {
1595
+ targetModelResource = joinPath(target, sourceModelResource.path.substr(source.path.length + 1));
1596
+ }
1597
+ modelsToRestore.push({
1598
+ source: sourceModelResource,
1599
+ target: targetModelResource,
1600
+ languageId: sourceModel.getLanguageId(),
1601
+ encoding: sourceModel.getEncoding(),
1602
+ snapshot: sourceModel.isDirty() ? sourceModel.createSnapshot() : undefined
1603
+ });
1604
+ }
1605
+ }
1606
+ }
1607
+ this.mapCorrelationIdToModelsToRestore.set(e.correlationId, modelsToRestore);
1608
+ }
1609
+ }
1610
+ onDidFailWorkingCopyFileOperation(e) {
1611
+ if (((e.operation === 2 || e.operation === 3) )) {
1612
+ const modelsToRestore = this.mapCorrelationIdToModelsToRestore.get(e.correlationId);
1613
+ if (modelsToRestore) {
1614
+ this.mapCorrelationIdToModelsToRestore.delete(e.correlationId);
1615
+ modelsToRestore.forEach(model => {
1616
+ if (model.snapshot) {
1617
+ this.get(model.source)?.setDirty(true);
1618
+ }
1619
+ });
1620
+ }
1621
+ }
1622
+ }
1623
+ onDidRunWorkingCopyFileOperation(e) {
1624
+ switch (e.operation) {
1625
+ case 0 :
1626
+ e.waitUntil((async () => {
1627
+ for (const { target } of e.files) {
1628
+ const model = this.get(target);
1629
+ if (model && !model.isDisposed()) {
1630
+ await model.revert();
1631
+ }
1632
+ }
1633
+ })());
1634
+ break;
1635
+ case 2 :
1636
+ case 3 :
1637
+ e.waitUntil((async () => {
1638
+ const modelsToRestore = this.mapCorrelationIdToModelsToRestore.get(e.correlationId);
1639
+ if (modelsToRestore) {
1640
+ this.mapCorrelationIdToModelsToRestore.delete(e.correlationId);
1641
+ await Promises.settled(( (modelsToRestore.map(async (modelToRestore) => {
1642
+ const restoredModel = await this.resolve(modelToRestore.target, {
1643
+ reload: { async: false },
1644
+ contents: modelToRestore.snapshot ? createTextBufferFactoryFromSnapshot(modelToRestore.snapshot) : undefined,
1645
+ encoding: modelToRestore.encoding
1646
+ });
1647
+ if (modelToRestore.languageId &&
1648
+ modelToRestore.languageId !== PLAINTEXT_LANGUAGE_ID &&
1649
+ restoredModel.getLanguageId() === PLAINTEXT_LANGUAGE_ID &&
1650
+ extname$1(modelToRestore.target) !== PLAINTEXT_EXTENSION) {
1651
+ restoredModel.updateTextEditorModel(undefined, modelToRestore.languageId);
1652
+ }
1653
+ }))));
1654
+ }
1655
+ })());
1656
+ break;
1657
+ }
1658
+ }
1659
+ get(resource) {
1660
+ return this.mapResourceToModel.get(resource);
1661
+ }
1662
+ has(resource) {
1663
+ return this.mapResourceToModel.has(resource);
1664
+ }
1665
+ async reload(model) {
1666
+ await this.joinPendingResolves(model.resource);
1667
+ if (model.isDirty() || model.isDisposed() || !this.has(model.resource)) {
1668
+ return;
1669
+ }
1670
+ await this.doResolve(model, { reload: { async: false } });
1671
+ }
1672
+ async resolve(resource, options) {
1673
+ const pendingResolve = this.joinPendingResolves(resource);
1674
+ if (pendingResolve) {
1675
+ await pendingResolve;
1676
+ }
1677
+ return this.doResolve(resource, options);
1678
+ }
1679
+ async doResolve(resourceOrModel, options) {
1680
+ let model;
1681
+ let resource;
1682
+ if (URI.isUri(resourceOrModel)) {
1683
+ resource = resourceOrModel;
1684
+ model = this.get(resource);
1685
+ }
1686
+ else {
1687
+ resource = resourceOrModel.resource;
1688
+ model = resourceOrModel;
1689
+ }
1690
+ let modelResolve;
1691
+ let didCreateModel = false;
1692
+ if (model) {
1693
+ if (options?.contents) {
1694
+ modelResolve = model.resolve(options);
1695
+ }
1696
+ else if (options?.reload) {
1697
+ if (options.reload.async) {
1698
+ modelResolve = Promise.resolve();
1699
+ (async () => {
1700
+ try {
1701
+ await model.resolve(options);
1702
+ }
1703
+ catch (error) {
1704
+ onUnexpectedError(error);
1705
+ }
1706
+ })();
1707
+ }
1708
+ else {
1709
+ modelResolve = model.resolve(options);
1710
+ }
1711
+ }
1712
+ else {
1713
+ modelResolve = Promise.resolve();
1714
+ }
1715
+ }
1716
+ else {
1717
+ didCreateModel = true;
1718
+ const newModel = model = this.instantiationService.createInstance(TextFileEditorModel, resource, options ? options.encoding : undefined, options ? options.languageId : undefined);
1719
+ modelResolve = model.resolve(options);
1720
+ this.registerModel(newModel);
1721
+ }
1722
+ this.mapResourceToPendingModelResolvers.set(resource, modelResolve);
1723
+ this.add(resource, model);
1724
+ if (didCreateModel) {
1725
+ this._onDidCreate.fire(model);
1726
+ if (model.isDirty()) {
1727
+ this._onDidChangeDirty.fire(model);
1728
+ }
1729
+ }
1730
+ try {
1731
+ await modelResolve;
1732
+ }
1733
+ catch (error) {
1734
+ if (didCreateModel) {
1735
+ model.dispose();
1736
+ }
1737
+ throw error;
1738
+ }
1739
+ finally {
1740
+ this.mapResourceToPendingModelResolvers.delete(resource);
1741
+ }
1742
+ if (options?.languageId) {
1743
+ model.setLanguageId(options.languageId);
1744
+ }
1745
+ if (didCreateModel && model.isDirty()) {
1746
+ this._onDidChangeDirty.fire(model);
1747
+ }
1748
+ return model;
1749
+ }
1750
+ joinPendingResolves(resource) {
1751
+ const pendingModelResolve = this.mapResourceToPendingModelResolvers.get(resource);
1752
+ if (!pendingModelResolve) {
1753
+ return;
1754
+ }
1755
+ return this.doJoinPendingResolves(resource);
1756
+ }
1757
+ async doJoinPendingResolves(resource) {
1758
+ let currentModelCopyResolve;
1759
+ while (this.mapResourceToPendingModelResolvers.has(resource)) {
1760
+ const nextPendingModelResolve = this.mapResourceToPendingModelResolvers.get(resource);
1761
+ if (nextPendingModelResolve === currentModelCopyResolve) {
1762
+ return;
1763
+ }
1764
+ currentModelCopyResolve = nextPendingModelResolve;
1765
+ try {
1766
+ await nextPendingModelResolve;
1767
+ }
1768
+ catch (error) {
1769
+ }
1770
+ }
1771
+ }
1772
+ registerModel(model) {
1773
+ const modelListeners = ( (new DisposableStore()));
1774
+ modelListeners.add(model.onDidResolve(reason => this._onDidResolve.fire({ model, reason })));
1775
+ modelListeners.add(model.onDidChangeDirty(() => this._onDidChangeDirty.fire(model)));
1776
+ modelListeners.add(model.onDidChangeReadonly(() => this._onDidChangeReadonly.fire(model)));
1777
+ modelListeners.add(model.onDidChangeOrphaned(() => this._onDidChangeOrphaned.fire(model)));
1778
+ modelListeners.add(model.onDidSaveError(() => this._onDidSaveError.fire(model)));
1779
+ modelListeners.add(model.onDidSave(e => this._onDidSave.fire({ model, ...e })));
1780
+ modelListeners.add(model.onDidRevert(() => this._onDidRevert.fire(model)));
1781
+ modelListeners.add(model.onDidChangeEncoding(() => this._onDidChangeEncoding.fire(model)));
1782
+ this.mapResourceToModelListeners.set(model.resource, modelListeners);
1783
+ }
1784
+ add(resource, model) {
1785
+ const knownModel = this.mapResourceToModel.get(resource);
1786
+ if (knownModel === model) {
1787
+ return;
1788
+ }
1789
+ const disposeListener = this.mapResourceToDisposeListener.get(resource);
1790
+ disposeListener?.dispose();
1791
+ this.mapResourceToModel.set(resource, model);
1792
+ this.mapResourceToDisposeListener.set(resource, model.onWillDispose(() => this.remove(resource)));
1793
+ }
1794
+ remove(resource) {
1795
+ const removed = this.mapResourceToModel.delete(resource);
1796
+ const disposeListener = this.mapResourceToDisposeListener.get(resource);
1797
+ if (disposeListener) {
1798
+ dispose(disposeListener);
1799
+ this.mapResourceToDisposeListener.delete(resource);
1800
+ }
1801
+ const modelListener = this.mapResourceToModelListeners.get(resource);
1802
+ if (modelListener) {
1803
+ dispose(modelListener);
1804
+ this.mapResourceToModelListeners.delete(resource);
1805
+ }
1806
+ if (removed) {
1807
+ this._onDidRemove.fire(resource);
1808
+ }
1809
+ }
1810
+ addSaveParticipant(participant) {
1811
+ return this.saveParticipants.addSaveParticipant(participant);
1812
+ }
1813
+ runSaveParticipants(model, context, token) {
1814
+ return this.saveParticipants.participate(model, context, token);
1815
+ }
1816
+ canDispose(model) {
1817
+ if (model.isDisposed() ||
1818
+ (!this.mapResourceToPendingModelResolvers.has(model.resource) && !model.isDirty())) {
1819
+ return true;
1820
+ }
1821
+ return this.doCanDispose(model);
1822
+ }
1823
+ async doCanDispose(model) {
1824
+ const pendingResolve = this.joinPendingResolves(model.resource);
1825
+ if (pendingResolve) {
1826
+ await pendingResolve;
1827
+ return this.canDispose(model);
1828
+ }
1829
+ if (model.isDirty()) {
1830
+ await Event.toPromise(model.onDidChangeDirty);
1831
+ return this.canDispose(model);
1832
+ }
1833
+ return true;
1834
+ }
1835
+ dispose() {
1836
+ super.dispose();
1837
+ this.mapResourceToModel.clear();
1838
+ this.mapResourceToPendingModelResolvers.clear();
1839
+ dispose(( (this.mapResourceToDisposeListener.values())));
1840
+ this.mapResourceToDisposeListener.clear();
1841
+ dispose(( (this.mapResourceToModelListeners.values())));
1842
+ this.mapResourceToModelListeners.clear();
1843
+ }
1844
+ };
1845
+ TextFileEditorModelManager = ( (__decorate([
1846
+ ( (__param(0, IInstantiationService))),
1847
+ ( (__param(1, IFileService))),
1848
+ ( (__param(2, INotificationService))),
1849
+ ( (__param(3, IWorkingCopyFileService))),
1850
+ ( (__param(4, IUriIdentityService)))
1851
+ ], TextFileEditorModelManager)));
1852
+ let AbstractTextFileService = class AbstractTextFileService extends Disposable {
1853
+ constructor(fileService, untitledTextEditorService, lifecycleService, instantiationService, modelService, environmentService, dialogService, fileDialogService, textResourceConfigurationService, filesConfigurationService, codeEditorService, pathService, workingCopyFileService, uriIdentityService, languageService, logService, elevatedFileService, decorationsService) {
1854
+ super();
1855
+ this.fileService = fileService;
1856
+ this.untitledTextEditorService = untitledTextEditorService;
1857
+ this.lifecycleService = lifecycleService;
1858
+ this.instantiationService = instantiationService;
1859
+ this.modelService = modelService;
1860
+ this.environmentService = environmentService;
1861
+ this.dialogService = dialogService;
1862
+ this.fileDialogService = fileDialogService;
1863
+ this.textResourceConfigurationService = textResourceConfigurationService;
1864
+ this.filesConfigurationService = filesConfigurationService;
1865
+ this.codeEditorService = codeEditorService;
1866
+ this.pathService = pathService;
1867
+ this.workingCopyFileService = workingCopyFileService;
1868
+ this.uriIdentityService = uriIdentityService;
1869
+ this.languageService = languageService;
1870
+ this.logService = logService;
1871
+ this.elevatedFileService = elevatedFileService;
1872
+ this.decorationsService = decorationsService;
1873
+ this.files = this._register(this.instantiationService.createInstance(TextFileEditorModelManager));
1874
+ this.untitled = this.untitledTextEditorService;
1875
+ this.provideDecorations();
1876
+ }
1877
+ provideDecorations() {
1878
+ this.decorationsService.registerDecorationsProvider(new (class extends Disposable {
1879
+ constructor(files) {
1880
+ super();
1881
+ this.files = files;
1882
+ this.label = ( (localize('textFileModelDecorations', "Text File Model Decorations")));
1883
+ this._onDidChange = this._register(( (new Emitter())));
1884
+ this.onDidChange = this._onDidChange.event;
1885
+ this.registerListeners();
1886
+ }
1887
+ registerListeners() {
1888
+ this._register(this.files.onDidResolve(({ model }) => {
1889
+ if (model.isReadonly() || model.hasState(4 )) {
1890
+ this._onDidChange.fire([model.resource]);
1891
+ }
1892
+ }));
1893
+ this._register(this.files.onDidRemove(modelUri => this._onDidChange.fire([modelUri])));
1894
+ this._register(this.files.onDidChangeReadonly(model => this._onDidChange.fire([model.resource])));
1895
+ this._register(this.files.onDidChangeOrphaned(model => this._onDidChange.fire([model.resource])));
1896
+ }
1897
+ provideDecorations(uri) {
1898
+ const model = this.files.get(uri);
1899
+ if (!model || model.isDisposed()) {
1900
+ return undefined;
1901
+ }
1902
+ const isReadonly = model.isReadonly();
1903
+ const isOrphaned = model.hasState(4 );
1904
+ if (isReadonly && isOrphaned) {
1905
+ return {
1906
+ color: listErrorForeground,
1907
+ letter: Codicon.lockSmall,
1908
+ strikethrough: true,
1909
+ tooltip: ( (localize('readonlyAndDeleted', "Deleted, Read Only"))),
1910
+ };
1911
+ }
1912
+ else if (isReadonly) {
1913
+ return {
1914
+ letter: Codicon.lockSmall,
1915
+ tooltip: ( (localize('readonly', "Read Only"))),
1916
+ };
1917
+ }
1918
+ else if (isOrphaned) {
1919
+ return {
1920
+ color: listErrorForeground,
1921
+ strikethrough: true,
1922
+ tooltip: ( (localize('deleted', "Deleted"))),
1923
+ };
1924
+ }
1925
+ return undefined;
1926
+ }
1927
+ })(this.files));
1928
+ }
1929
+ get encoding() {
1930
+ if (!this._encoding) {
1931
+ this._encoding = this._register(this.instantiationService.createInstance(EncodingOracle));
1932
+ }
1933
+ return this._encoding;
1934
+ }
1935
+ async read(resource, options) {
1936
+ const [bufferStream, decoder] = await this.doRead(resource, {
1937
+ ...options,
1938
+ preferUnbuffered: true
1939
+ });
1940
+ return {
1941
+ ...bufferStream,
1942
+ encoding: decoder.detected.encoding || UTF8,
1943
+ value: await consumeStream(decoder.stream, strings => strings.join(''))
1944
+ };
1945
+ }
1946
+ async readStream(resource, options) {
1947
+ const [bufferStream, decoder] = await this.doRead(resource, options);
1948
+ return {
1949
+ ...bufferStream,
1950
+ encoding: decoder.detected.encoding || UTF8,
1951
+ value: await createTextBufferFactoryFromStream(decoder.stream)
1952
+ };
1953
+ }
1954
+ async doRead(resource, options) {
1955
+ const cts = ( (new CancellationTokenSource()));
1956
+ let bufferStream;
1957
+ if (options?.preferUnbuffered) {
1958
+ const content = await this.fileService.readFile(resource, options, cts.token);
1959
+ bufferStream = {
1960
+ ...content,
1961
+ value: bufferToStream(content.value)
1962
+ };
1963
+ }
1964
+ else {
1965
+ bufferStream = await this.fileService.readFileStream(resource, options, cts.token);
1966
+ }
1967
+ try {
1968
+ const decoder = await this.doGetDecodedStream(resource, bufferStream.value, options);
1969
+ return [bufferStream, decoder];
1970
+ }
1971
+ catch (error) {
1972
+ cts.dispose(true);
1973
+ if (error.decodeStreamErrorKind === 1 ) {
1974
+ throw new TextFileOperationError(localize('fileBinaryError', "File seems to be binary and cannot be opened as text"), 0 , options);
1975
+ }
1976
+ else {
1977
+ throw error;
1978
+ }
1979
+ }
1980
+ }
1981
+ async create(operations, undoInfo) {
1982
+ const operationsWithContents = await Promise.all(( (operations.map(async (operation) => {
1983
+ const contents = await this.getEncodedReadable(operation.resource, operation.value);
1984
+ return {
1985
+ resource: operation.resource,
1986
+ contents,
1987
+ overwrite: operation.options?.overwrite
1988
+ };
1989
+ }))));
1990
+ return this.workingCopyFileService.create(operationsWithContents, CancellationToken.None, undoInfo);
1991
+ }
1992
+ async write(resource, value, options) {
1993
+ const readable = await this.getEncodedReadable(resource, value, options);
1994
+ if (options?.writeElevated && this.elevatedFileService.isSupported(resource)) {
1995
+ return this.elevatedFileService.writeFileElevated(resource, readable, options);
1996
+ }
1997
+ return this.fileService.writeFile(resource, readable, options);
1998
+ }
1999
+ async getEncodedReadable(resource, value, options) {
2000
+ const { encoding, addBOM } = await this.encoding.getWriteEncoding(resource, options);
2001
+ if (encoding === UTF8 && !addBOM) {
2002
+ return typeof value === 'undefined'
2003
+ ? undefined
2004
+ : toBufferOrReadable(value);
2005
+ }
2006
+ value = value || '';
2007
+ const snapshot = typeof value === 'string' ? stringToSnapshot(value) : value;
2008
+ return toEncodeReadable(snapshot, encoding, { addBOM });
2009
+ }
2010
+ async getDecodedStream(resource, value, options) {
2011
+ return (await this.doGetDecodedStream(resource, value, options)).stream;
2012
+ }
2013
+ doGetDecodedStream(resource, stream, options) {
2014
+ return toDecodeStream(stream, {
2015
+ acceptTextOnly: options?.acceptTextOnly ?? false,
2016
+ guessEncoding: options?.autoGuessEncoding || this.textResourceConfigurationService.getValue(resource, 'files.autoGuessEncoding'),
2017
+ overwriteEncoding: async (detectedEncoding) => {
2018
+ const { encoding } = await this.encoding.getPreferredReadEncoding(resource, options, withNullAsUndefined(detectedEncoding));
2019
+ return encoding;
2020
+ }
2021
+ });
2022
+ }
2023
+ async save(resource, options) {
2024
+ if (resource.scheme === Schemas.untitled) {
2025
+ const model = this.untitled.get(resource);
2026
+ if (model) {
2027
+ let targetUri;
2028
+ if (model.hasAssociatedFilePath) {
2029
+ targetUri = await this.suggestSavePath(resource);
2030
+ }
2031
+ else {
2032
+ targetUri = await this.fileDialogService.pickFileToSave(await this.suggestSavePath(resource), options?.availableFileSystems);
2033
+ }
2034
+ if (targetUri) {
2035
+ return this.saveAs(resource, targetUri, options);
2036
+ }
2037
+ }
2038
+ }
2039
+ else {
2040
+ const model = this.files.get(resource);
2041
+ if (model) {
2042
+ return (await model.save(options)) ? resource : undefined;
2043
+ }
2044
+ }
2045
+ return undefined;
2046
+ }
2047
+ async saveAs(source, target, options) {
2048
+ if (!target) {
2049
+ target = await this.fileDialogService.pickFileToSave(await this.suggestSavePath(options?.suggestedTarget ?? source), options?.availableFileSystems);
2050
+ }
2051
+ if (!target) {
2052
+ return;
2053
+ }
2054
+ if (isEqual(source, target)) {
2055
+ return this.save(source, { ...options, force: true });
2056
+ }
2057
+ if (this.fileService.hasProvider(source) && this.uriIdentityService.extUri.isEqual(source, target) && (await this.fileService.exists(source))) {
2058
+ await this.workingCopyFileService.move([{ file: { source, target } }], CancellationToken.None);
2059
+ const success = await this.save(source, options);
2060
+ if (!success) {
2061
+ await this.save(target, options);
2062
+ }
2063
+ return target;
2064
+ }
2065
+ return this.doSaveAs(source, target, options);
2066
+ }
2067
+ async doSaveAs(source, target, options) {
2068
+ let success = false;
2069
+ const textFileModel = this.files.get(source);
2070
+ if (textFileModel?.isResolved()) {
2071
+ success = await this.doSaveAsTextFile(textFileModel, source, target, options);
2072
+ }
2073
+ else if (this.fileService.hasProvider(source)) {
2074
+ await this.fileService.copy(source, target, true);
2075
+ success = true;
2076
+ }
2077
+ else {
2078
+ const textModel = this.modelService.getModel(source);
2079
+ if (textModel) {
2080
+ success = await this.doSaveAsTextFile(textModel, source, target, options);
2081
+ }
2082
+ }
2083
+ if (!success) {
2084
+ return undefined;
2085
+ }
2086
+ try {
2087
+ await this.revert(source);
2088
+ }
2089
+ catch (error) {
2090
+ this.logService.error(error);
2091
+ }
2092
+ return target;
2093
+ }
2094
+ async doSaveAsTextFile(sourceModel, source, target, options) {
2095
+ let sourceModelEncoding = undefined;
2096
+ const sourceModelWithEncodingSupport = sourceModel;
2097
+ if (typeof sourceModelWithEncodingSupport.getEncoding === 'function') {
2098
+ sourceModelEncoding = sourceModelWithEncodingSupport.getEncoding();
2099
+ }
2100
+ let targetExists = false;
2101
+ let targetModel = this.files.get(target);
2102
+ if (targetModel?.isResolved()) {
2103
+ targetExists = true;
2104
+ }
2105
+ else {
2106
+ targetExists = await this.fileService.exists(target);
2107
+ if (!targetExists) {
2108
+ await this.create([{ resource: target, value: '' }]);
2109
+ }
2110
+ try {
2111
+ targetModel = await this.files.resolve(target, { encoding: sourceModelEncoding });
2112
+ }
2113
+ catch (error) {
2114
+ if (targetExists) {
2115
+ if (error.textFileOperationResult === 0 ||
2116
+ error.fileOperationResult === 7 ) {
2117
+ await this.fileService.del(target);
2118
+ return this.doSaveAsTextFile(sourceModel, source, target, options);
2119
+ }
2120
+ }
2121
+ throw error;
2122
+ }
2123
+ }
2124
+ let write;
2125
+ if (sourceModel instanceof UntitledTextEditorModel && sourceModel.hasAssociatedFilePath && targetExists && this.uriIdentityService.extUri.isEqual(target, toLocalResource(sourceModel.resource, this.environmentService.remoteAuthority, this.pathService.defaultUriScheme))) {
2126
+ write = await this.confirmOverwrite(target);
2127
+ }
2128
+ else {
2129
+ write = true;
2130
+ }
2131
+ if (!write) {
2132
+ return false;
2133
+ }
2134
+ let sourceTextModel = undefined;
2135
+ if (sourceModel instanceof BaseTextEditorModel) {
2136
+ if (sourceModel.isResolved()) {
2137
+ sourceTextModel = sourceModel.textEditorModel;
2138
+ }
2139
+ }
2140
+ else {
2141
+ sourceTextModel = sourceModel;
2142
+ }
2143
+ let targetTextModel = undefined;
2144
+ if (targetModel.isResolved()) {
2145
+ targetTextModel = targetModel.textEditorModel;
2146
+ }
2147
+ if (sourceTextModel && targetTextModel) {
2148
+ targetModel.updatePreferredEncoding(sourceModelEncoding);
2149
+ this.modelService.updateModel(targetTextModel, createTextBufferFactoryFromSnapshot(sourceTextModel.createSnapshot()));
2150
+ const sourceLanguageId = sourceTextModel.getLanguageId();
2151
+ const targetLanguageId = targetTextModel.getLanguageId();
2152
+ if (sourceLanguageId !== PLAINTEXT_LANGUAGE_ID && targetLanguageId === PLAINTEXT_LANGUAGE_ID) {
2153
+ targetTextModel.setMode(sourceLanguageId);
2154
+ }
2155
+ const sourceTransientProperties = this.codeEditorService.getTransientModelProperties(sourceTextModel);
2156
+ if (sourceTransientProperties) {
2157
+ for (const [key, value] of sourceTransientProperties) {
2158
+ this.codeEditorService.setTransientModelProperty(targetTextModel, key, value);
2159
+ }
2160
+ }
2161
+ }
2162
+ if (!options?.source) {
2163
+ options = {
2164
+ ...options,
2165
+ source: targetExists ? AbstractTextFileService.TEXTFILE_SAVE_REPLACE_SOURCE : AbstractTextFileService.TEXTFILE_SAVE_CREATE_SOURCE
2166
+ };
2167
+ }
2168
+ return targetModel.save(options);
2169
+ }
2170
+ async confirmOverwrite(resource) {
2171
+ const { confirmed } = await this.dialogService.confirm({
2172
+ type: 'warning',
2173
+ message: ( (localize(
2174
+ 'confirmOverwrite',
2175
+ "'{0}' already exists. Do you want to replace it?",
2176
+ basename(resource)
2177
+ ))),
2178
+ detail: ( (localize(
2179
+ 'irreversible',
2180
+ "A file or folder with the name '{0}' already exists in the folder '{1}'. Replacing it will overwrite its current contents.",
2181
+ basename(resource),
2182
+ basename(dirname(resource))
2183
+ ))),
2184
+ primaryButton: ( (localize(
2185
+ { key: 'replaceButtonLabel', comment: ['&& denotes a mnemonic'] },
2186
+ "&&Replace"
2187
+ ))),
2188
+ });
2189
+ return confirmed;
2190
+ }
2191
+ async suggestSavePath(resource) {
2192
+ if (this.fileService.hasProvider(resource)) {
2193
+ return resource;
2194
+ }
2195
+ const remoteAuthority = this.environmentService.remoteAuthority;
2196
+ const defaultFilePath = await this.fileDialogService.defaultFilePath();
2197
+ let suggestedFilename = undefined;
2198
+ if (resource.scheme === Schemas.untitled) {
2199
+ const model = this.untitled.get(resource);
2200
+ if (model) {
2201
+ if (model.hasAssociatedFilePath) {
2202
+ return toLocalResource(resource, remoteAuthority, this.pathService.defaultUriScheme);
2203
+ }
2204
+ let nameCandidate;
2205
+ if (await this.pathService.hasValidBasename(joinPath(defaultFilePath, model.name), model.name)) {
2206
+ nameCandidate = model.name;
2207
+ }
2208
+ else {
2209
+ nameCandidate = basename(resource);
2210
+ }
2211
+ const languageId = model.getLanguageId();
2212
+ if (languageId && languageId !== PLAINTEXT_LANGUAGE_ID) {
2213
+ suggestedFilename = this.suggestFilename(languageId, nameCandidate);
2214
+ }
2215
+ else {
2216
+ suggestedFilename = nameCandidate;
2217
+ }
2218
+ }
2219
+ }
2220
+ if (!suggestedFilename) {
2221
+ suggestedFilename = basename(resource);
2222
+ }
2223
+ return joinPath(defaultFilePath, suggestedFilename);
2224
+ }
2225
+ suggestFilename(languageId, untitledName) {
2226
+ const languageName = this.languageService.getLanguageName(languageId);
2227
+ if (!languageName) {
2228
+ return untitledName;
2229
+ }
2230
+ const untitledExtension = extname(untitledName);
2231
+ const extensions = this.languageService.getExtensions(languageId);
2232
+ if (extensions.includes(untitledExtension)) {
2233
+ return untitledName;
2234
+ }
2235
+ const primaryExtension = firstOrDefault(extensions);
2236
+ if (primaryExtension) {
2237
+ if (untitledExtension) {
2238
+ return `${untitledName.substring(0, untitledName.indexOf(untitledExtension))}${primaryExtension}`;
2239
+ }
2240
+ return `${untitledName}${primaryExtension}`;
2241
+ }
2242
+ const filenames = this.languageService.getFilenames(languageId);
2243
+ if (filenames.includes(untitledName)) {
2244
+ return untitledName;
2245
+ }
2246
+ return firstOrDefault(filenames) ?? untitledName;
2247
+ }
2248
+ async revert(resource, options) {
2249
+ if (resource.scheme === Schemas.untitled) {
2250
+ const model = this.untitled.get(resource);
2251
+ if (model) {
2252
+ return model.revert(options);
2253
+ }
2254
+ }
2255
+ else {
2256
+ const model = this.files.get(resource);
2257
+ if (model && (model.isDirty() || options?.force)) {
2258
+ return model.revert(options);
2259
+ }
2260
+ }
2261
+ }
2262
+ isDirty(resource) {
2263
+ const model = resource.scheme === Schemas.untitled ? this.untitled.get(resource) : this.files.get(resource);
2264
+ if (model) {
2265
+ return model.isDirty();
2266
+ }
2267
+ return false;
2268
+ }
2269
+ };
2270
+ AbstractTextFileService.TEXTFILE_SAVE_CREATE_SOURCE = SaveSourceRegistry.registerSource('textFileCreate.source', ( (localize('textFileCreate.source', "File Created"))));
2271
+ AbstractTextFileService.TEXTFILE_SAVE_REPLACE_SOURCE = SaveSourceRegistry.registerSource('textFileOverwrite.source', ( (localize('textFileOverwrite.source', "File Replaced"))));
2272
+ AbstractTextFileService = ( (__decorate([
2273
+ ( (__param(0, IFileService))),
2274
+ ( (__param(1, IUntitledTextEditorService))),
2275
+ ( (__param(2, ILifecycleService))),
2276
+ ( (__param(3, IInstantiationService))),
2277
+ ( (__param(4, IModelService))),
2278
+ ( (__param(5, IWorkbenchEnvironmentService))),
2279
+ ( (__param(6, IDialogService))),
2280
+ ( (__param(7, IFileDialogService))),
2281
+ ( (__param(8, ITextResourceConfigurationService))),
2282
+ ( (__param(9, IFilesConfigurationService))),
2283
+ ( (__param(10, ICodeEditorService))),
2284
+ ( (__param(11, IPathService))),
2285
+ ( (__param(12, IWorkingCopyFileService))),
2286
+ ( (__param(13, IUriIdentityService))),
2287
+ ( (__param(14, ILanguageService))),
2288
+ ( (__param(15, ILogService))),
2289
+ ( (__param(16, IElevatedFileService))),
2290
+ ( (__param(17, IDecorationsService)))
2291
+ ], AbstractTextFileService)));
2292
+ let EncodingOracle = class EncodingOracle extends Disposable {
2293
+ get encodingOverrides() { return this._encodingOverrides; }
2294
+ set encodingOverrides(value) { this._encodingOverrides = value; }
2295
+ constructor(textResourceConfigurationService, environmentService, contextService, uriIdentityService) {
2296
+ super();
2297
+ this.textResourceConfigurationService = textResourceConfigurationService;
2298
+ this.environmentService = environmentService;
2299
+ this.contextService = contextService;
2300
+ this.uriIdentityService = uriIdentityService;
2301
+ this._encodingOverrides = this.getDefaultEncodingOverrides();
2302
+ this.registerListeners();
2303
+ }
2304
+ registerListeners() {
2305
+ this._register(this.contextService.onDidChangeWorkspaceFolders(() => this.encodingOverrides = this.getDefaultEncodingOverrides()));
2306
+ }
2307
+ getDefaultEncodingOverrides() {
2308
+ const defaultEncodingOverrides = [];
2309
+ defaultEncodingOverrides.push({ parent: this.environmentService.userRoamingDataHome, encoding: UTF8 });
2310
+ defaultEncodingOverrides.push({ extension: WORKSPACE_EXTENSION, encoding: UTF8 });
2311
+ defaultEncodingOverrides.push({ parent: this.environmentService.untitledWorkspacesHome, encoding: UTF8 });
2312
+ this.contextService.getWorkspace().folders.forEach(folder => {
2313
+ defaultEncodingOverrides.push({ parent: joinPath(folder.uri, '.vscode'), encoding: UTF8 });
2314
+ });
2315
+ return defaultEncodingOverrides;
2316
+ }
2317
+ async getWriteEncoding(resource, options) {
2318
+ const { encoding, hasBOM } = await this.getPreferredWriteEncoding(resource, options ? options.encoding : undefined);
2319
+ return { encoding, addBOM: hasBOM };
2320
+ }
2321
+ async getPreferredWriteEncoding(resource, preferredEncoding) {
2322
+ const resourceEncoding = await this.getEncodingForResource(resource, preferredEncoding);
2323
+ return {
2324
+ encoding: resourceEncoding,
2325
+ hasBOM: resourceEncoding === UTF16be || resourceEncoding === UTF16le || resourceEncoding === UTF8_with_bom
2326
+ };
2327
+ }
2328
+ async getPreferredReadEncoding(resource, options, detectedEncoding) {
2329
+ let preferredEncoding;
2330
+ if (options?.encoding) {
2331
+ if (detectedEncoding === UTF8_with_bom && options.encoding === UTF8) {
2332
+ preferredEncoding = UTF8_with_bom;
2333
+ }
2334
+ else {
2335
+ preferredEncoding = options.encoding;
2336
+ }
2337
+ }
2338
+ else if (typeof detectedEncoding === 'string') {
2339
+ preferredEncoding = detectedEncoding;
2340
+ }
2341
+ else if (this.textResourceConfigurationService.getValue(resource, 'files.encoding') === UTF8_with_bom) {
2342
+ preferredEncoding = UTF8;
2343
+ }
2344
+ const encoding = await this.getEncodingForResource(resource, preferredEncoding);
2345
+ return {
2346
+ encoding,
2347
+ hasBOM: encoding === UTF16be || encoding === UTF16le || encoding === UTF8_with_bom
2348
+ };
2349
+ }
2350
+ async getEncodingForResource(resource, preferredEncoding) {
2351
+ let fileEncoding;
2352
+ const override = this.getEncodingOverride(resource);
2353
+ if (override) {
2354
+ fileEncoding = override;
2355
+ }
2356
+ else if (preferredEncoding) {
2357
+ fileEncoding = preferredEncoding;
2358
+ }
2359
+ else {
2360
+ fileEncoding = this.textResourceConfigurationService.getValue(resource, 'files.encoding');
2361
+ }
2362
+ if (fileEncoding !== UTF8) {
2363
+ if (!fileEncoding || !(await encodingExists(fileEncoding))) {
2364
+ fileEncoding = UTF8;
2365
+ }
2366
+ }
2367
+ return fileEncoding;
2368
+ }
2369
+ getEncodingOverride(resource) {
2370
+ if (this.encodingOverrides?.length) {
2371
+ for (const override of this.encodingOverrides) {
2372
+ if (override.parent && this.uriIdentityService.extUri.isEqualOrParent(resource, override.parent)) {
2373
+ return override.encoding;
2374
+ }
2375
+ if (override.extension && extname$1(resource) === `.${override.extension}`) {
2376
+ return override.encoding;
2377
+ }
2378
+ }
2379
+ }
2380
+ return undefined;
2381
+ }
2382
+ };
2383
+ EncodingOracle = ( (__decorate([
2384
+ ( (__param(0, ITextResourceConfigurationService))),
2385
+ ( (__param(1, IWorkbenchEnvironmentService))),
2386
+ ( (__param(2, IWorkspaceContextService))),
2387
+ ( (__param(3, IUriIdentityService)))
2388
+ ], EncodingOracle)));
2389
+ let BrowserTextFileService = class BrowserTextFileService extends AbstractTextFileService {
2390
+ constructor(fileService, untitledTextEditorService, lifecycleService, instantiationService, modelService, environmentService, dialogService, fileDialogService, textResourceConfigurationService, filesConfigurationService, codeEditorService, pathService, workingCopyFileService, uriIdentityService, languageService, elevatedFileService, logService, decorationsService) {
2391
+ super(fileService, untitledTextEditorService, lifecycleService, instantiationService, modelService, environmentService, dialogService, fileDialogService, textResourceConfigurationService, filesConfigurationService, codeEditorService, pathService, workingCopyFileService, uriIdentityService, languageService, logService, elevatedFileService, decorationsService);
2392
+ this.registerListeners();
2393
+ }
2394
+ registerListeners() {
2395
+ this.lifecycleService.onBeforeShutdown(event => event.veto(this.onBeforeShutdown(), 'veto.textFiles'));
2396
+ }
2397
+ onBeforeShutdown() {
2398
+ if (this.files.models.some(model => model.hasState(2 ))) {
2399
+ return true;
2400
+ }
2401
+ return false;
2402
+ }
2403
+ };
2404
+ BrowserTextFileService = ( (__decorate([
2405
+ ( (__param(0, IFileService))),
2406
+ ( (__param(1, IUntitledTextEditorService))),
2407
+ ( (__param(2, ILifecycleService))),
2408
+ ( (__param(3, IInstantiationService))),
2409
+ ( (__param(4, IModelService))),
2410
+ ( (__param(5, IWorkbenchEnvironmentService))),
2411
+ ( (__param(6, IDialogService))),
2412
+ ( (__param(7, IFileDialogService))),
2413
+ ( (__param(8, ITextResourceConfigurationService))),
2414
+ ( (__param(9, IFilesConfigurationService))),
2415
+ ( (__param(10, ICodeEditorService))),
2416
+ ( (__param(11, IPathService))),
2417
+ ( (__param(12, IWorkingCopyFileService))),
2418
+ ( (__param(13, IUriIdentityService))),
2419
+ ( (__param(14, ILanguageService))),
2420
+ ( (__param(15, IElevatedFileService))),
2421
+ ( (__param(16, ILogService))),
2422
+ ( (__param(17, IDecorationsService)))
2423
+ ], BrowserTextFileService)));
1351
2424
  let SimpleExtensionResourceLoaderService = class SimpleExtensionResourceLoaderService extends AbstractExtensionResourceLoaderService {
1352
2425
  constructor(fileService, storageService, productService, environmentService, configurationService) {
1353
2426
  super(fileService, storageService, productService, environmentService, configurationService);
@@ -1419,20 +2492,20 @@ let MemoryFileService = class MemoryFileService extends FileService {
1419
2492
  constructor(logService) {
1420
2493
  super(logService);
1421
2494
  this.registerProvider('user', new InMemoryFileSystemProvider());
1422
- const extension = Services.get().extension ?? DEFAULT_EXTENSION;
1423
- this.registerProvider(extension.extensionLocation.scheme, extensionFileSystemProvider);
2495
+ this.registerProvider('extension', extensionFileSystemProvider);
1424
2496
  }
1425
2497
  };
1426
2498
  MemoryFileService = ( __decorate([
1427
2499
  ( __param(0, ILogService))
1428
2500
  ], MemoryFileService));
1429
- function registerExtensionFile(resource, getContent) {
1430
- return extensionFileSystemProvider.registerFile(resource, getContent);
2501
+ function registerExtensionFile(extensionLocation, path, getContent) {
2502
+ return extensionFileSystemProvider.registerFile(joinPath(extensionLocation, path), getContent);
1431
2503
  }
1432
2504
  function getServiceOverride() {
1433
2505
  return {
1434
2506
  [( IFileService.toString())]: new SyncDescriptor(MemoryFileService),
1435
- [( IExtensionResourceLoaderService.toString())]: new SyncDescriptor(SimpleExtensionResourceLoaderService)
2507
+ [( IExtensionResourceLoaderService.toString())]: new SyncDescriptor(SimpleExtensionResourceLoaderService),
2508
+ [( ITextFileService.toString())]: new SyncDescriptor(BrowserTextFileService)
1436
2509
  };
1437
2510
  }
1438
- export { IExtensionResourceLoaderService as I, getServiceOverride as g, registerExtensionFile as r };
2511
+ export { getServiceOverride as g, registerExtensionFile as r };