@codingame/monaco-vscode-configuration-service-override 5.2.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,13 +4,15 @@ import { parse } from 'vscode/vscode/vs/base/common/json';
4
4
  import { setProperty } from 'vscode/vscode/vs/base/common/jsonEdit';
5
5
  import { Queue } from 'vscode/vscode/vs/base/common/async';
6
6
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
7
+ import { WorkbenchState } from 'vscode/vscode/vs/platform/workspace/common/workspace';
7
8
  import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
8
9
  import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles.service';
9
10
  import { TASKS_CONFIGURATION_KEY, LAUNCH_CONFIGURATION_KEY, TASKS_DEFAULT, FOLDER_SCOPES, USER_STANDALONE_CONFIGURATIONS, WORKSPACE_STANDALONE_CONFIGURATIONS, FOLDER_SETTINGS_PATH } from 'vscode/vscode/vs/workbench/services/configuration/common/configuration';
10
11
  import { IWorkbenchConfigurationService } from 'vscode/vscode/vs/workbench/services/configuration/common/configuration.service';
12
+ import { FileOperationResult } from 'vscode/vscode/vs/platform/files/common/files';
11
13
  import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
12
14
  import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
13
- import { Extensions, OVERRIDE_PROPERTY_REGEX, keyFromOverrideIdentifiers } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
15
+ import { Extensions, OVERRIDE_PROPERTY_REGEX, ConfigurationScope, keyFromOverrideIdentifiers } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
14
16
  import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
15
17
  import 'vscode/vscode/vs/platform/notification/common/notification';
16
18
  import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification.service';
@@ -25,12 +27,36 @@ import { ErrorNoTelemetry } from 'vscode/vscode/vs/base/common/errors';
25
27
  import Severity$1 from 'vscode/vscode/vs/base/common/severity';
26
28
 
27
29
  const _moduleId = "vs/workbench/services/configuration/common/configurationEditing";
30
+ var ConfigurationEditingErrorCode;
31
+ ( ((function(ConfigurationEditingErrorCode) {
32
+ ConfigurationEditingErrorCode[ConfigurationEditingErrorCode["ERROR_UNKNOWN_KEY"] = 0] = "ERROR_UNKNOWN_KEY";
33
+ ConfigurationEditingErrorCode[ConfigurationEditingErrorCode["ERROR_INVALID_WORKSPACE_CONFIGURATION_APPLICATION"] = 1] = "ERROR_INVALID_WORKSPACE_CONFIGURATION_APPLICATION";
34
+ ConfigurationEditingErrorCode[ConfigurationEditingErrorCode["ERROR_INVALID_WORKSPACE_CONFIGURATION_MACHINE"] = 2] = "ERROR_INVALID_WORKSPACE_CONFIGURATION_MACHINE";
35
+ ConfigurationEditingErrorCode[ConfigurationEditingErrorCode["ERROR_INVALID_FOLDER_CONFIGURATION"] = 3] = "ERROR_INVALID_FOLDER_CONFIGURATION";
36
+ ConfigurationEditingErrorCode[ConfigurationEditingErrorCode["ERROR_INVALID_USER_TARGET"] = 4] = "ERROR_INVALID_USER_TARGET";
37
+ ConfigurationEditingErrorCode[ConfigurationEditingErrorCode["ERROR_INVALID_WORKSPACE_TARGET"] = 5] = "ERROR_INVALID_WORKSPACE_TARGET";
38
+ ConfigurationEditingErrorCode[ConfigurationEditingErrorCode["ERROR_INVALID_FOLDER_TARGET"] = 6] = "ERROR_INVALID_FOLDER_TARGET";
39
+ ConfigurationEditingErrorCode[ConfigurationEditingErrorCode["ERROR_INVALID_RESOURCE_LANGUAGE_CONFIGURATION"] = 7] = "ERROR_INVALID_RESOURCE_LANGUAGE_CONFIGURATION";
40
+ ConfigurationEditingErrorCode[ConfigurationEditingErrorCode["ERROR_NO_WORKSPACE_OPENED"] = 8] = "ERROR_NO_WORKSPACE_OPENED";
41
+ ConfigurationEditingErrorCode[ConfigurationEditingErrorCode["ERROR_CONFIGURATION_FILE_DIRTY"] = 9] = "ERROR_CONFIGURATION_FILE_DIRTY";
42
+ ConfigurationEditingErrorCode[ConfigurationEditingErrorCode["ERROR_CONFIGURATION_FILE_MODIFIED_SINCE"] = 10] = "ERROR_CONFIGURATION_FILE_MODIFIED_SINCE";
43
+ ConfigurationEditingErrorCode[ConfigurationEditingErrorCode["ERROR_INVALID_CONFIGURATION"] = 11] = "ERROR_INVALID_CONFIGURATION";
44
+ ConfigurationEditingErrorCode[ConfigurationEditingErrorCode["ERROR_POLICY_CONFIGURATION"] = 12] = "ERROR_POLICY_CONFIGURATION";
45
+ ConfigurationEditingErrorCode[ConfigurationEditingErrorCode["ERROR_INTERNAL"] = 13] = "ERROR_INTERNAL";
46
+ })(ConfigurationEditingErrorCode || (ConfigurationEditingErrorCode = {}))));
28
47
  class ConfigurationEditingError extends ErrorNoTelemetry {
29
48
  constructor(message, code) {
30
49
  super(message);
31
50
  this.code = code;
32
51
  }
33
52
  }
53
+ var EditableConfigurationTarget;
54
+ ( ((function(EditableConfigurationTarget) {
55
+ EditableConfigurationTarget[EditableConfigurationTarget["USER_LOCAL"] = 1] = "USER_LOCAL";
56
+ EditableConfigurationTarget[EditableConfigurationTarget["USER_REMOTE"] = 2] = "USER_REMOTE";
57
+ EditableConfigurationTarget[EditableConfigurationTarget["WORKSPACE"] = 3] = "WORKSPACE";
58
+ EditableConfigurationTarget[EditableConfigurationTarget["WORKSPACE_FOLDER"] = 4] = "WORKSPACE_FOLDER";
59
+ })(EditableConfigurationTarget || (EditableConfigurationTarget = {}))));
34
60
  let ConfigurationEditing = class ConfigurationEditing {
35
61
  constructor(remoteSettingsResource, configurationService, contextService, userDataProfileService, userDataProfilesService, fileService, textModelResolverService, textFileService, notificationService, preferencesService, editorService, uriIdentityService) {
36
62
  this.remoteSettingsResource = remoteSettingsResource;
@@ -75,7 +101,7 @@ let ConfigurationEditing = class ConfigurationEditing {
75
101
  }
76
102
  async updateConfiguration(operation, model, formattingOptions, options) {
77
103
  if (this.hasParseErrors(model.getValue(), operation)) {
78
- throw this.toConfigurationEditingError(11 , operation.target, operation);
104
+ throw this.toConfigurationEditingError(ConfigurationEditingErrorCode.ERROR_INVALID_CONFIGURATION, operation.target, operation);
79
105
  }
80
106
  if (this.textFileService.isDirty(model.uri) && options.handleDirtyFile) {
81
107
  switch (options.handleDirtyFile) {
@@ -97,8 +123,8 @@ let ConfigurationEditing = class ConfigurationEditing {
97
123
  await this.textFileService.save(model.uri, { ignoreErrorHandler: true });
98
124
  }
99
125
  catch (error) {
100
- if (error.fileOperationResult === 3 ) {
101
- throw this.toConfigurationEditingError(10 , operation.target, operation);
126
+ if (error.fileOperationResult === FileOperationResult.FILE_MODIFIED_SINCE) {
127
+ throw this.toConfigurationEditingError(ConfigurationEditingErrorCode.ERROR_CONFIGURATION_FILE_MODIFIED_SINCE, operation.target, operation);
102
128
  }
103
129
  throw ( (new ConfigurationEditingError(localizeWithPath(
104
130
  _moduleId,
@@ -106,7 +132,7 @@ let ConfigurationEditing = class ConfigurationEditing {
106
132
  "Error while writing to {0}. {1}",
107
133
  this.stringifyTarget(operation.target),
108
134
  error.message
109
- ), 13 )));
135
+ ), ConfigurationEditingErrorCode.ERROR_INTERNAL)));
110
136
  }
111
137
  }
112
138
  applyEditsToBuffer(edit, model) {
@@ -149,13 +175,13 @@ let ConfigurationEditing = class ConfigurationEditing {
149
175
  }
150
176
  async onError(error, operation, scopes) {
151
177
  switch (error.code) {
152
- case 11 :
178
+ case ConfigurationEditingErrorCode.ERROR_INVALID_CONFIGURATION:
153
179
  this.onInvalidConfigurationError(error, operation);
154
180
  break;
155
- case 9 :
181
+ case ConfigurationEditingErrorCode.ERROR_CONFIGURATION_FILE_DIRTY:
156
182
  this.onConfigurationFileDirtyError(error, operation, scopes);
157
183
  break;
158
- case 10 :
184
+ case ConfigurationEditingErrorCode.ERROR_CONFIGURATION_FILE_MODIFIED_SINCE:
159
185
  return this.doWriteConfiguration(operation, { scopes, handleDirtyFile: 'revert' });
160
186
  default:
161
187
  this.notificationService.error(error.message);
@@ -209,16 +235,16 @@ let ConfigurationEditing = class ConfigurationEditing {
209
235
  openSettings(operation) {
210
236
  const options = { jsonEditor: true };
211
237
  switch (operation.target) {
212
- case 1 :
238
+ case EditableConfigurationTarget.USER_LOCAL:
213
239
  this.preferencesService.openUserSettings(options);
214
240
  break;
215
- case 2 :
241
+ case EditableConfigurationTarget.USER_REMOTE:
216
242
  this.preferencesService.openRemoteSettings(options);
217
243
  break;
218
- case 3 :
244
+ case EditableConfigurationTarget.WORKSPACE:
219
245
  this.preferencesService.openWorkspaceSettings(options);
220
246
  break;
221
- case 4 :
247
+ case EditableConfigurationTarget.WORKSPACE_FOLDER:
222
248
  if (operation.resource) {
223
249
  const workspaceFolder = this.contextService.getWorkspaceFolder(operation.resource);
224
250
  if (workspaceFolder) {
@@ -239,67 +265,67 @@ let ConfigurationEditing = class ConfigurationEditing {
239
265
  }
240
266
  toErrorMessage(error, target, operation) {
241
267
  switch (error) {
242
- case 12 : return ( localizeWithPath(
268
+ case ConfigurationEditingErrorCode.ERROR_POLICY_CONFIGURATION: return ( localizeWithPath(
243
269
  _moduleId,
244
270
  5,
245
271
  "Unable to write {0} because it is configured in system policy.",
246
272
  operation.key
247
273
  ));
248
- case 0 : return ( localizeWithPath(
274
+ case ConfigurationEditingErrorCode.ERROR_UNKNOWN_KEY: return ( localizeWithPath(
249
275
  _moduleId,
250
276
  6,
251
277
  "Unable to write to {0} because {1} is not a registered configuration.",
252
278
  this.stringifyTarget(target),
253
279
  operation.key
254
280
  ));
255
- case 1 : return ( localizeWithPath(
281
+ case ConfigurationEditingErrorCode.ERROR_INVALID_WORKSPACE_CONFIGURATION_APPLICATION: return ( localizeWithPath(
256
282
  _moduleId,
257
283
  7,
258
284
  "Unable to write {0} to Workspace Settings. This setting can be written only into User settings.",
259
285
  operation.key
260
286
  ));
261
- case 2 : return ( localizeWithPath(
287
+ case ConfigurationEditingErrorCode.ERROR_INVALID_WORKSPACE_CONFIGURATION_MACHINE: return ( localizeWithPath(
262
288
  _moduleId,
263
289
  8,
264
290
  "Unable to write {0} to Workspace Settings. This setting can be written only into User settings.",
265
291
  operation.key
266
292
  ));
267
- case 3 : return ( localizeWithPath(
293
+ case ConfigurationEditingErrorCode.ERROR_INVALID_FOLDER_CONFIGURATION: return ( localizeWithPath(
268
294
  _moduleId,
269
295
  9,
270
296
  "Unable to write to Folder Settings because {0} does not support the folder resource scope.",
271
297
  operation.key
272
298
  ));
273
- case 4 : return ( localizeWithPath(
299
+ case ConfigurationEditingErrorCode.ERROR_INVALID_USER_TARGET: return ( localizeWithPath(
274
300
  _moduleId,
275
301
  10,
276
302
  "Unable to write to User Settings because {0} does not support for global scope.",
277
303
  operation.key
278
304
  ));
279
- case 5 : return ( localizeWithPath(
305
+ case ConfigurationEditingErrorCode.ERROR_INVALID_WORKSPACE_TARGET: return ( localizeWithPath(
280
306
  _moduleId,
281
307
  11,
282
308
  "Unable to write to Workspace Settings because {0} does not support for workspace scope in a multi folder workspace.",
283
309
  operation.key
284
310
  ));
285
- case 6 : return ( localizeWithPath(
311
+ case ConfigurationEditingErrorCode.ERROR_INVALID_FOLDER_TARGET: return ( localizeWithPath(
286
312
  _moduleId,
287
313
  12,
288
314
  "Unable to write to Folder Settings because no resource is provided."
289
315
  ));
290
- case 7 : return ( localizeWithPath(
316
+ case ConfigurationEditingErrorCode.ERROR_INVALID_RESOURCE_LANGUAGE_CONFIGURATION: return ( localizeWithPath(
291
317
  _moduleId,
292
318
  13,
293
319
  "Unable to write to Language Settings because {0} is not a resource language setting.",
294
320
  operation.key
295
321
  ));
296
- case 8 : return ( localizeWithPath(
322
+ case ConfigurationEditingErrorCode.ERROR_NO_WORKSPACE_OPENED: return ( localizeWithPath(
297
323
  _moduleId,
298
324
  14,
299
325
  "Unable to write to {0} because no workspace is opened. Please open a workspace first and try again.",
300
326
  this.stringifyTarget(target)
301
327
  ));
302
- case 11 : {
328
+ case ConfigurationEditingErrorCode.ERROR_INVALID_CONFIGURATION: {
303
329
  if (operation.workspaceStandAloneConfigurationKey === TASKS_CONFIGURATION_KEY) {
304
330
  return ( localizeWithPath(
305
331
  _moduleId,
@@ -315,25 +341,25 @@ let ConfigurationEditing = class ConfigurationEditing {
315
341
  ));
316
342
  }
317
343
  switch (target) {
318
- case 1 :
344
+ case EditableConfigurationTarget.USER_LOCAL:
319
345
  return ( localizeWithPath(
320
346
  _moduleId,
321
347
  17,
322
348
  "Unable to write into user settings. Please open the user settings to correct errors/warnings in it and try again."
323
349
  ));
324
- case 2 :
350
+ case EditableConfigurationTarget.USER_REMOTE:
325
351
  return ( localizeWithPath(
326
352
  _moduleId,
327
353
  18,
328
354
  "Unable to write into remote user settings. Please open the remote user settings to correct errors/warnings in it and try again."
329
355
  ));
330
- case 3 :
356
+ case EditableConfigurationTarget.WORKSPACE:
331
357
  return ( localizeWithPath(
332
358
  _moduleId,
333
359
  19,
334
360
  "Unable to write into workspace settings. Please open the workspace settings to correct errors/warnings in the file and try again."
335
361
  ));
336
- case 4 : {
362
+ case EditableConfigurationTarget.WORKSPACE_FOLDER: {
337
363
  let workspaceFolderName = '<<unknown>>';
338
364
  if (operation.resource) {
339
365
  const folder = this.contextService.getWorkspaceFolder(operation.resource);
@@ -352,7 +378,7 @@ let ConfigurationEditing = class ConfigurationEditing {
352
378
  return '';
353
379
  }
354
380
  }
355
- case 9 : {
381
+ case ConfigurationEditingErrorCode.ERROR_CONFIGURATION_FILE_DIRTY: {
356
382
  if (operation.workspaceStandAloneConfigurationKey === TASKS_CONFIGURATION_KEY) {
357
383
  return ( localizeWithPath(
358
384
  _moduleId,
@@ -368,25 +394,25 @@ let ConfigurationEditing = class ConfigurationEditing {
368
394
  ));
369
395
  }
370
396
  switch (target) {
371
- case 1 :
397
+ case EditableConfigurationTarget.USER_LOCAL:
372
398
  return ( localizeWithPath(
373
399
  _moduleId,
374
400
  23,
375
401
  "Unable to write into user settings because the file has unsaved changes. Please save the user settings file first and then try again."
376
402
  ));
377
- case 2 :
403
+ case EditableConfigurationTarget.USER_REMOTE:
378
404
  return ( localizeWithPath(
379
405
  _moduleId,
380
406
  24,
381
407
  "Unable to write into remote user settings because the file has unsaved changes. Please save the remote user settings file first and then try again."
382
408
  ));
383
- case 3 :
409
+ case EditableConfigurationTarget.WORKSPACE:
384
410
  return ( localizeWithPath(
385
411
  _moduleId,
386
412
  25,
387
413
  "Unable to write into workspace settings because the file has unsaved changes. Please save the workspace settings file first and then try again."
388
414
  ));
389
- case 4 : {
415
+ case EditableConfigurationTarget.WORKSPACE_FOLDER: {
390
416
  let workspaceFolderName = '<<unknown>>';
391
417
  if (operation.resource) {
392
418
  const folder = this.contextService.getWorkspaceFolder(operation.resource);
@@ -405,7 +431,7 @@ let ConfigurationEditing = class ConfigurationEditing {
405
431
  return '';
406
432
  }
407
433
  }
408
- case 10 :
434
+ case ConfigurationEditingErrorCode.ERROR_CONFIGURATION_FILE_MODIFIED_SINCE:
409
435
  if (operation.workspaceStandAloneConfigurationKey === TASKS_CONFIGURATION_KEY) {
410
436
  return ( localizeWithPath(
411
437
  _moduleId,
@@ -421,32 +447,32 @@ let ConfigurationEditing = class ConfigurationEditing {
421
447
  ));
422
448
  }
423
449
  switch (target) {
424
- case 1 :
450
+ case EditableConfigurationTarget.USER_LOCAL:
425
451
  return ( localizeWithPath(
426
452
  _moduleId,
427
453
  29,
428
454
  "Unable to write into user settings because the content of the file is newer."
429
455
  ));
430
- case 2 :
456
+ case EditableConfigurationTarget.USER_REMOTE:
431
457
  return ( localizeWithPath(
432
458
  _moduleId,
433
459
  30,
434
460
  "Unable to write into remote user settings because the content of the file is newer."
435
461
  ));
436
- case 3 :
462
+ case EditableConfigurationTarget.WORKSPACE:
437
463
  return ( localizeWithPath(
438
464
  _moduleId,
439
465
  31,
440
466
  "Unable to write into workspace settings because the content of the file is newer."
441
467
  ));
442
- case 4 :
468
+ case EditableConfigurationTarget.WORKSPACE_FOLDER:
443
469
  return ( localizeWithPath(
444
470
  _moduleId,
445
471
  32,
446
472
  "Unable to write into folder settings because the content of the file is newer."
447
473
  ));
448
474
  }
449
- case 13 : return ( localizeWithPath(
475
+ case ConfigurationEditingErrorCode.ERROR_INTERNAL: return ( localizeWithPath(
450
476
  _moduleId,
451
477
  33,
452
478
  "Unable to write to {0} because of an internal error.",
@@ -456,13 +482,13 @@ let ConfigurationEditing = class ConfigurationEditing {
456
482
  }
457
483
  stringifyTarget(target) {
458
484
  switch (target) {
459
- case 1 :
485
+ case EditableConfigurationTarget.USER_LOCAL:
460
486
  return ( localizeWithPath(_moduleId, 34, "User Settings"));
461
- case 2 :
487
+ case EditableConfigurationTarget.USER_REMOTE:
462
488
  return ( localizeWithPath(_moduleId, 35, "Remote User Settings"));
463
- case 3 :
489
+ case EditableConfigurationTarget.WORKSPACE:
464
490
  return ( localizeWithPath(_moduleId, 36, "Workspace Settings"));
465
- case 4 :
491
+ case EditableConfigurationTarget.WORKSPACE_FOLDER:
466
492
  return ( localizeWithPath(_moduleId, 37, "Folder Settings"));
467
493
  default:
468
494
  return '';
@@ -493,59 +519,59 @@ let ConfigurationEditing = class ConfigurationEditing {
493
519
  }
494
520
  async validate(target, operation, checkDirty, overrides) {
495
521
  if (this.configurationService.inspect(operation.key).policyValue !== undefined) {
496
- throw this.toConfigurationEditingError(12 , target, operation);
522
+ throw this.toConfigurationEditingError(ConfigurationEditingErrorCode.ERROR_POLICY_CONFIGURATION, target, operation);
497
523
  }
498
524
  const configurationProperties = ( (Registry.as(Extensions.Configuration))).getConfigurationProperties();
499
525
  const configurationScope = configurationProperties[operation.key]?.scope;
500
526
  if (!operation.workspaceStandAloneConfigurationKey) {
501
527
  const validKeys = ( (this.configurationService.keys())).default;
502
528
  if (validKeys.indexOf(operation.key) < 0 && !OVERRIDE_PROPERTY_REGEX.test(operation.key) && operation.value !== undefined) {
503
- throw this.toConfigurationEditingError(0 , target, operation);
529
+ throw this.toConfigurationEditingError(ConfigurationEditingErrorCode.ERROR_UNKNOWN_KEY, target, operation);
504
530
  }
505
531
  }
506
532
  if (operation.workspaceStandAloneConfigurationKey) {
507
- if ((operation.workspaceStandAloneConfigurationKey !== TASKS_CONFIGURATION_KEY) && ((target === 1 || target === 2) )) {
508
- throw this.toConfigurationEditingError(4 , target, operation);
533
+ if ((operation.workspaceStandAloneConfigurationKey !== TASKS_CONFIGURATION_KEY) && (target === EditableConfigurationTarget.USER_LOCAL || target === EditableConfigurationTarget.USER_REMOTE)) {
534
+ throw this.toConfigurationEditingError(ConfigurationEditingErrorCode.ERROR_INVALID_USER_TARGET, target, operation);
509
535
  }
510
536
  }
511
- if (((target === 3 || target === 4) ) && this.contextService.getWorkbenchState() === 1 ) {
512
- throw this.toConfigurationEditingError(8 , target, operation);
537
+ if ((target === EditableConfigurationTarget.WORKSPACE || target === EditableConfigurationTarget.WORKSPACE_FOLDER) && this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) {
538
+ throw this.toConfigurationEditingError(ConfigurationEditingErrorCode.ERROR_NO_WORKSPACE_OPENED, target, operation);
513
539
  }
514
- if (target === 3 ) {
540
+ if (target === EditableConfigurationTarget.WORKSPACE) {
515
541
  if (!operation.workspaceStandAloneConfigurationKey && !OVERRIDE_PROPERTY_REGEX.test(operation.key)) {
516
- if (configurationScope === 1 ) {
517
- throw this.toConfigurationEditingError(1 , target, operation);
542
+ if (configurationScope === ConfigurationScope.APPLICATION) {
543
+ throw this.toConfigurationEditingError(ConfigurationEditingErrorCode.ERROR_INVALID_WORKSPACE_CONFIGURATION_APPLICATION, target, operation);
518
544
  }
519
- if (configurationScope === 2 ) {
520
- throw this.toConfigurationEditingError(2 , target, operation);
545
+ if (configurationScope === ConfigurationScope.MACHINE) {
546
+ throw this.toConfigurationEditingError(ConfigurationEditingErrorCode.ERROR_INVALID_WORKSPACE_CONFIGURATION_MACHINE, target, operation);
521
547
  }
522
548
  }
523
549
  }
524
- if (target === 4 ) {
550
+ if (target === EditableConfigurationTarget.WORKSPACE_FOLDER) {
525
551
  if (!operation.resource) {
526
- throw this.toConfigurationEditingError(6 , target, operation);
552
+ throw this.toConfigurationEditingError(ConfigurationEditingErrorCode.ERROR_INVALID_FOLDER_TARGET, target, operation);
527
553
  }
528
554
  if (!operation.workspaceStandAloneConfigurationKey && !OVERRIDE_PROPERTY_REGEX.test(operation.key)) {
529
555
  if (configurationScope !== undefined && !FOLDER_SCOPES.includes(configurationScope)) {
530
- throw this.toConfigurationEditingError(3 , target, operation);
556
+ throw this.toConfigurationEditingError(ConfigurationEditingErrorCode.ERROR_INVALID_FOLDER_CONFIGURATION, target, operation);
531
557
  }
532
558
  }
533
559
  }
534
560
  if (overrides.overrideIdentifiers?.length) {
535
- if (configurationScope !== 5 ) {
536
- throw this.toConfigurationEditingError(7 , target, operation);
561
+ if (configurationScope !== ConfigurationScope.LANGUAGE_OVERRIDABLE) {
562
+ throw this.toConfigurationEditingError(ConfigurationEditingErrorCode.ERROR_INVALID_RESOURCE_LANGUAGE_CONFIGURATION, target, operation);
537
563
  }
538
564
  }
539
565
  if (!operation.resource) {
540
- throw this.toConfigurationEditingError(6 , target, operation);
566
+ throw this.toConfigurationEditingError(ConfigurationEditingErrorCode.ERROR_INVALID_FOLDER_TARGET, target, operation);
541
567
  }
542
568
  if (checkDirty && this.textFileService.isDirty(operation.resource)) {
543
- throw this.toConfigurationEditingError(9 , target, operation);
569
+ throw this.toConfigurationEditingError(ConfigurationEditingErrorCode.ERROR_CONFIGURATION_FILE_DIRTY, target, operation);
544
570
  }
545
571
  }
546
572
  getConfigurationEditOperation(target, config, overrides) {
547
573
  if (config.key) {
548
- const standaloneConfigurationMap = target === 1 ? USER_STANDALONE_CONFIGURATIONS : WORKSPACE_STANDALONE_CONFIGURATIONS;
574
+ const standaloneConfigurationMap = target === EditableConfigurationTarget.USER_LOCAL ? USER_STANDALONE_CONFIGURATIONS : WORKSPACE_STANDALONE_CONFIGURATIONS;
549
575
  const standaloneConfigurationKeys = ( (Object.keys(standaloneConfigurationMap)));
550
576
  for (const key of standaloneConfigurationKeys) {
551
577
  const resource = this.getConfigurationFileResource(target, key, standaloneConfigurationMap[key], overrides.resource, undefined);
@@ -564,7 +590,7 @@ let ConfigurationEditing = class ConfigurationEditing {
564
590
  const configurationProperties = ( (Registry.as(Extensions.Configuration))).getConfigurationProperties();
565
591
  const configurationScope = configurationProperties[key]?.scope;
566
592
  let jsonPath = overrides.overrideIdentifiers?.length ? [keyFromOverrideIdentifiers(overrides.overrideIdentifiers), key] : [key];
567
- if (target === 1 || target === 2 ) {
593
+ if (target === EditableConfigurationTarget.USER_LOCAL || target === EditableConfigurationTarget.USER_REMOTE) {
568
594
  return { key, jsonPath, value: config.value, resource: this.getConfigurationFileResource(target, key, '', null, configurationScope) ?? undefined, target };
569
595
  }
570
596
  const resource = this.getConfigurationFileResource(target, key, FOLDER_SETTINGS_PATH, overrides.resource, configurationScope);
@@ -578,7 +604,7 @@ let ConfigurationEditing = class ConfigurationEditing {
578
604
  return !!(workspace.configuration && resource && workspace.configuration.fsPath === resource.fsPath);
579
605
  }
580
606
  getConfigurationFileResource(target, key, relativePath, resource, scope) {
581
- if (target === 1 ) {
607
+ if (target === EditableConfigurationTarget.USER_LOCAL) {
582
608
  if (key === TASKS_CONFIGURATION_KEY) {
583
609
  return this.userDataProfileService.currentProfile.tasksResource;
584
610
  }
@@ -589,21 +615,21 @@ let ConfigurationEditing = class ConfigurationEditing {
589
615
  return this.userDataProfileService.currentProfile.settingsResource;
590
616
  }
591
617
  }
592
- if (target === 2 ) {
618
+ if (target === EditableConfigurationTarget.USER_REMOTE) {
593
619
  return this.remoteSettingsResource;
594
620
  }
595
621
  const workbenchState = this.contextService.getWorkbenchState();
596
- if (workbenchState !== 1 ) {
622
+ if (workbenchState !== WorkbenchState.EMPTY) {
597
623
  const workspace = this.contextService.getWorkspace();
598
- if (target === 3 ) {
599
- if (workbenchState === 3 ) {
624
+ if (target === EditableConfigurationTarget.WORKSPACE) {
625
+ if (workbenchState === WorkbenchState.WORKSPACE) {
600
626
  return workspace.configuration ?? null;
601
627
  }
602
- if (workbenchState === 2 ) {
628
+ if (workbenchState === WorkbenchState.FOLDER) {
603
629
  return workspace.folders[0].toResource(relativePath);
604
630
  }
605
631
  }
606
- if (target === 4 ) {
632
+ if (target === EditableConfigurationTarget.WORKSPACE_FOLDER) {
607
633
  if (resource) {
608
634
  const folder = this.contextService.getWorkspaceFolder(resource);
609
635
  if (folder) {
@@ -629,4 +655,4 @@ ConfigurationEditing = ( (__decorate([
629
655
  ( (__param(11, IUriIdentityService)))
630
656
  ], ConfigurationEditing)));
631
657
 
632
- export { ConfigurationEditing, ConfigurationEditingError };
658
+ export { ConfigurationEditing, ConfigurationEditingError, ConfigurationEditingErrorCode, EditableConfigurationTarget };
@@ -11,15 +11,19 @@ import { isWorkspace, toWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier,
11
11
  import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
12
12
  import { basenameOrAuthority, basename, joinPath, dirname } from 'vscode/vscode/vs/base/common/resources';
13
13
  import { getPathLabel, tildify } from 'vscode/vscode/vs/base/common/labels';
14
+ import { Verbosity } from 'vscode/vscode/vs/platform/label/common/label';
14
15
  import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label.service';
15
16
  import { ExtensionsRegistry } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
16
17
  import { match } from 'vscode/vscode/vs/base/common/glob';
18
+ import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
17
19
  import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
20
+ import 'vscode/vscode/vs/platform/instantiation/common/extensions';
18
21
  import { IPathService } from 'vscode/vscode/vs/workbench/services/path/common/pathService.service';
19
22
  import { isProposedApiEnabled } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
20
- import { OS } from 'vscode/vscode/vs/base/common/platform';
23
+ import { OS, OperatingSystem } from 'vscode/vscode/vs/base/common/platform';
21
24
  import { IRemoteAgentService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
22
25
  import { Schemas } from 'vscode/vscode/vs/base/common/network';
26
+ import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
23
27
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
24
28
  import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
25
29
  import { firstOrDefault } from 'vscode/vscode/vs/base/common/arrays';
@@ -131,7 +135,7 @@ let ResourceLabelFormattersHandler = class ResourceLabelFormattersHandler {
131
135
  ResourceLabelFormattersHandler = ( (__decorate([
132
136
  ( (__param(0, ILabelService)))
133
137
  ], ResourceLabelFormattersHandler)));
134
- ( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(ResourceLabelFormattersHandler, 3 );
138
+ ( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(ResourceLabelFormattersHandler, LifecyclePhase.Restored);
135
139
  const FORMATTER_CACHE_SIZE = 50;
136
140
  let LabelService = class LabelService extends Disposable {
137
141
  constructor(environmentService, contextService, pathService, remoteAgentService, storageService, lifecycleService) {
@@ -145,7 +149,7 @@ let LabelService = class LabelService extends Disposable {
145
149
  this.os = OS;
146
150
  this.userHome = pathService.defaultUriScheme === Schemas.file ? this.pathService.userHome({ preferLocal: true }) : undefined;
147
151
  const memento = this.storedFormattersMemento = ( (new Memento('cachedResourceLabelFormatters2', storageService)));
148
- this.storedFormatters = memento.getMemento(0 , 1 );
152
+ this.storedFormatters = memento.getMemento(StorageScope.PROFILE, StorageTarget.MACHINE);
149
153
  this.formatters = this.storedFormatters?.formatters?.slice() || [];
150
154
  this.resolveRemoteEnvironment();
151
155
  }
@@ -242,7 +246,7 @@ let LabelService = class LabelService extends Disposable {
242
246
  pathLib = posix;
243
247
  }
244
248
  else {
245
- pathLib = ((this.os === 1) ) ? win32 : posix;
249
+ pathLib = (this.os === OperatingSystem.Windows) ? win32 : posix;
246
250
  }
247
251
  return pathLib.basename(label);
248
252
  }
@@ -278,10 +282,10 @@ let LabelService = class LabelService extends Disposable {
278
282
  }
279
283
  let label;
280
284
  switch (options?.verbose) {
281
- case 0 :
285
+ case Verbosity.SHORT:
282
286
  label = filename;
283
287
  break;
284
- case 2 :
288
+ case Verbosity.LONG:
285
289
  label = ( localizeWithPath(
286
290
  _moduleId,
287
291
  11,
@@ -289,12 +293,12 @@ let LabelService = class LabelService extends Disposable {
289
293
  this.getUriLabel(joinPath(dirname(workspaceUri), filename))
290
294
  ));
291
295
  break;
292
- case 1 :
296
+ case Verbosity.MEDIUM:
293
297
  default:
294
298
  label = ( localizeWithPath(_moduleId, 12, "{0} (Workspace)", filename));
295
299
  break;
296
300
  }
297
- if (options?.verbose === 0 ) {
301
+ if (options?.verbose === Verbosity.SHORT) {
298
302
  return label;
299
303
  }
300
304
  return this.appendWorkspaceSuffix(label, workspaceUri);
@@ -302,16 +306,16 @@ let LabelService = class LabelService extends Disposable {
302
306
  doGetSingleFolderWorkspaceLabel(folderUri, options) {
303
307
  let label;
304
308
  switch (options?.verbose) {
305
- case 2 :
309
+ case Verbosity.LONG:
306
310
  label = this.getUriLabel(folderUri);
307
311
  break;
308
- case 0 :
309
- case 1 :
312
+ case Verbosity.SHORT:
313
+ case Verbosity.MEDIUM:
310
314
  default:
311
315
  label = basename(folderUri) || posix.sep;
312
316
  break;
313
317
  }
314
- if (options?.verbose === 0 ) {
318
+ if (options?.verbose === Verbosity.SHORT) {
315
319
  return label;
316
320
  }
317
321
  return this.appendWorkspaceSuffix(label, folderUri);
@@ -1,10 +1,12 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
3
3
  import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
4
- import { OS } from 'vscode/vscode/vs/base/common/platform';
4
+ import { OperatingSystem, OS } from 'vscode/vscode/vs/base/common/platform';
5
5
  import { Schemas } from 'vscode/vscode/vs/base/common/network';
6
+ import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
6
7
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
7
8
  import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
9
+ import 'vscode/vscode/vs/platform/instantiation/common/extensions';
8
10
  import { IRemoteAgentService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
9
11
 
10
12
  let TextResourcePropertiesService = class TextResourcePropertiesService {
@@ -21,7 +23,7 @@ let TextResourcePropertiesService = class TextResourcePropertiesService {
21
23
  return eol;
22
24
  }
23
25
  const os = this.getOS(resource);
24
- return os === 3 || os === 2 ? '\n' : '\r\n';
26
+ return os === OperatingSystem.Linux || os === OperatingSystem.Macintosh ? '\n' : '\r\n';
25
27
  }
26
28
  getOS(resource) {
27
29
  let os = OS;
@@ -29,8 +31,8 @@ let TextResourcePropertiesService = class TextResourcePropertiesService {
29
31
  if (remoteAuthority) {
30
32
  if (resource && resource.scheme !== Schemas.file) {
31
33
  const osCacheKey = `resource.authority.os.${remoteAuthority}`;
32
- os = this.remoteEnvironment ? this.remoteEnvironment.os : this.storageService.getNumber(osCacheKey, 1 , OS);
33
- this.storageService.store(osCacheKey, os, 1 , 1 );
34
+ os = this.remoteEnvironment ? this.remoteEnvironment.os : this.storageService.getNumber(osCacheKey, StorageScope.WORKSPACE, OS);
35
+ this.storageService.store(osCacheKey, os, StorageScope.WORKSPACE, StorageTarget.MACHINE);
34
36
  }
35
37
  }
36
38
  return os;