@codingame/monaco-vscode-configuration-service-override 5.3.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.
@@ -1,11 +1,12 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
- import { WORKSPACE_FILTER, hasWorkspaceFileExtension, WORKSPACE_EXTENSION, isSavedWorkspace, isUntitledWorkspace, toWorkspaceIdentifier, isWorkspaceIdentifier } from 'vscode/vscode/vs/platform/workspace/common/workspace';
3
+ import { WORKSPACE_FILTER, hasWorkspaceFileExtension, WORKSPACE_EXTENSION, isSavedWorkspace, WorkbenchState, isUntitledWorkspace, toWorkspaceIdentifier, isWorkspaceIdentifier } from 'vscode/vscode/vs/platform/workspace/common/workspace';
4
4
  import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
5
+ import { JSONEditingErrorCode } from '@codingame/monaco-vscode-base-service-override/vscode/vs/workbench/services/configuration/common/jsonEditing';
5
6
  import { IJSONEditingService } from 'vscode/vscode/vs/workbench/services/configuration/common/jsonEditing.service';
6
7
  import { rewriteWorkspaceFileForNewLocation } from 'vscode/vscode/vs/platform/workspaces/common/workspaces';
7
8
  import { IWorkspacesService } from 'vscode/vscode/vs/platform/workspaces/common/workspaces.service';
8
- import { Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
9
+ import { ConfigurationScope, Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
9
10
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
10
11
  import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands.service';
11
12
  import { firstOrDefault, distinct } from 'vscode/vscode/vs/base/common/arrays';
@@ -19,6 +20,7 @@ import { mnemonicButtonLabel } from 'vscode/vscode/vs/base/common/labels';
19
20
  import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles.service';
20
21
  import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host.service';
21
22
  import { Schemas } from 'vscode/vscode/vs/base/common/network';
23
+ import { SaveReason } from 'vscode/vscode/vs/workbench/common/editor';
22
24
  import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
23
25
  import { IWorkspaceTrustManagementService } from 'vscode/vscode/vs/platform/workspace/common/workspaceTrust.service';
24
26
  import { IWorkbenchConfigurationService } from 'vscode/vscode/vs/workbench/services/configuration/common/configuration.service';
@@ -104,7 +106,7 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService {
104
106
  if (this.includesSingleFolderWorkspace(foldersToDelete)) {
105
107
  return this.createAndEnterWorkspace(foldersToAdd);
106
108
  }
107
- if (this.contextService.getWorkbenchState() !== 3 ) {
109
+ if (this.contextService.getWorkbenchState() !== WorkbenchState.WORKSPACE) {
108
110
  return this.doAddFolders(foldersToAdd, index, donotNotifyError);
109
111
  }
110
112
  return this.doUpdateFolders(foldersToAdd, foldersToDelete, index, donotNotifyError);
@@ -129,11 +131,11 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService {
129
131
  }
130
132
  async doAddFolders(foldersToAdd, index, donotNotifyError = false) {
131
133
  const state = this.contextService.getWorkbenchState();
132
- if (state !== 3 ) {
134
+ if (state !== WorkbenchState.WORKSPACE) {
133
135
  let newWorkspaceFolders = ( (this.contextService.getWorkspace().folders.map(folder => ({ uri: folder.uri }))));
134
136
  newWorkspaceFolders.splice(typeof index === 'number' ? index : newWorkspaceFolders.length, 0, ...foldersToAdd);
135
137
  newWorkspaceFolders = distinct(newWorkspaceFolders, folder => this.uriIdentityService.extUri.getComparisonKey(folder.uri));
136
- if (state === 1 && newWorkspaceFolders.length === 0 || state === 2 && newWorkspaceFolders.length === 1) {
138
+ if (state === WorkbenchState.EMPTY && newWorkspaceFolders.length === 0 || state === WorkbenchState.FOLDER && newWorkspaceFolders.length === 1) {
137
139
  return;
138
140
  }
139
141
  return this.createAndEnterWorkspace(newWorkspaceFolders);
@@ -163,7 +165,7 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService {
163
165
  }
164
166
  }
165
167
  includesSingleFolderWorkspace(folders) {
166
- if (this.contextService.getWorkbenchState() === 2 ) {
168
+ if (this.contextService.getWorkbenchState() === WorkbenchState.FOLDER) {
167
169
  const workspaceFolder = this.contextService.getWorkspace().folders[0];
168
170
  return (
169
171
  (folders.some(
@@ -232,7 +234,7 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService {
232
234
  const configPathURI = workspace.configPath;
233
235
  const existingModel = this.textFileService.files.get(configPathURI);
234
236
  if (existingModel) {
235
- await existingModel.save({ force: true, reason: 1 });
237
+ await existingModel.save({ force: true, reason: SaveReason.EXPLICIT });
236
238
  return;
237
239
  }
238
240
  const workspaceFileExists = await this.fileService.exists(configPathURI);
@@ -245,7 +247,7 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService {
245
247
  }
246
248
  handleWorkspaceConfigurationEditingError(error) {
247
249
  switch (error.code) {
248
- case 0 :
250
+ case JSONEditingErrorCode.ERROR_INVALID_FILE:
249
251
  this.onInvalidWorkspaceConfigurationFileError();
250
252
  break;
251
253
  default:
@@ -271,14 +273,14 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService {
271
273
  throw ( (new Error('Entering a new workspace is not possible in tests.')));
272
274
  }
273
275
  const workspace = await this.workspacesService.getWorkspaceIdentifier(workspaceUri);
274
- if (this.contextService.getWorkbenchState() === 2 ) {
276
+ if (this.contextService.getWorkbenchState() === WorkbenchState.FOLDER) {
275
277
  await this.migrateWorkspaceSettings(workspace);
276
278
  }
277
279
  await this.configurationService.initialize(workspace);
278
280
  return this.workspacesService.enterWorkspace(workspaceUri);
279
281
  }
280
282
  migrateWorkspaceSettings(toWorkspace) {
281
- return this.doCopyWorkspaceSettings(toWorkspace, setting => setting.scope === 3 );
283
+ return this.doCopyWorkspaceSettings(toWorkspace, setting => setting.scope === ConfigurationScope.WINDOW);
282
284
  }
283
285
  copyWorkspaceSettings(toWorkspace) {
284
286
  return this.doCopyWorkspaceSettings(toWorkspace);
@@ -297,7 +299,7 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService {
297
299
  return this.jsonEditingService.write(toWorkspace.configPath, [{ path: ['settings'], value: targetWorkspaceConfiguration }], true);
298
300
  }
299
301
  async trustWorkspaceConfiguration(configPathURI) {
300
- if (this.contextService.getWorkbenchState() !== 1 && this.workspaceTrustManagementService.isWorkspaceTrusted()) {
302
+ if (this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY && this.workspaceTrustManagementService.isWorkspaceTrusted()) {
301
303
  await this.workspaceTrustManagementService.setUrisTrust([configPathURI], true);
302
304
  }
303
305
  }
@@ -1,13 +1,16 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import 'vscode/vscode/vs/platform/instantiation/common/extensions';
2
3
  import { restoreRecentlyOpened, isRecentFolder, isRecentWorkspace, isRecentFile, toStoreData, getStoredWorkspaceFolder } from 'vscode/vscode/vs/platform/workspaces/common/workspaces';
3
4
  import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
4
5
  import { Emitter } from 'vscode/vscode/vs/base/common/event';
6
+ import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
5
7
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
6
- import { isTemporaryWorkspace, WORKSPACE_EXTENSION } from 'vscode/vscode/vs/platform/workspace/common/workspace';
8
+ import { isTemporaryWorkspace, WorkbenchState, WORKSPACE_EXTENSION } from 'vscode/vscode/vs/platform/workspace/common/workspace';
7
9
  import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
8
10
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
9
11
  import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
10
12
  import { getWorkspaceIdentifier } from 'vscode/vscode/vs/workbench/services/workspaces/browser/workspaces';
13
+ import { FileOperationResult } from 'vscode/vscode/vs/platform/files/common/files';
11
14
  import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
12
15
  import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
13
16
  import { joinPath } from 'vscode/vscode/vs/base/common/resources';
@@ -33,7 +36,7 @@ let BrowserWorkspacesService = class BrowserWorkspacesService extends Disposable
33
36
  this.registerListeners();
34
37
  }
35
38
  registerListeners() {
36
- this._register(this.storageService.onDidChangeValue(-1 , BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, this._register(( new DisposableStore())))(() => this._onRecentlyOpenedChange.fire()));
39
+ this._register(this.storageService.onDidChangeValue(StorageScope.APPLICATION, BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, this._register(( new DisposableStore())))(() => this._onRecentlyOpenedChange.fire()));
37
40
  this._register(this.contextService.onDidChangeWorkspaceFolders(e => this.onDidChangeWorkspaceFolders(e)));
38
41
  }
39
42
  onDidChangeWorkspaceFolders(e) {
@@ -48,16 +51,16 @@ let BrowserWorkspacesService = class BrowserWorkspacesService extends Disposable
48
51
  const workspace = this.contextService.getWorkspace();
49
52
  const remoteAuthority = this.environmentService.remoteAuthority;
50
53
  switch (this.contextService.getWorkbenchState()) {
51
- case 2 :
54
+ case WorkbenchState.FOLDER:
52
55
  this.addRecentlyOpened([{ folderUri: workspace.folders[0].uri, remoteAuthority }]);
53
56
  break;
54
- case 3 :
57
+ case WorkbenchState.WORKSPACE:
55
58
  this.addRecentlyOpened([{ workspace: { id: workspace.id, configPath: workspace.configuration }, remoteAuthority }]);
56
59
  break;
57
60
  }
58
61
  }
59
62
  async getRecentlyOpened() {
60
- const recentlyOpenedRaw = this.storageService.get(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, -1 );
63
+ const recentlyOpenedRaw = this.storageService.get(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, StorageScope.APPLICATION);
61
64
  if (recentlyOpenedRaw) {
62
65
  const recentlyOpened = restoreRecentlyOpened(JSON.parse(recentlyOpenedRaw), this.logService);
63
66
  recentlyOpened.workspaces = recentlyOpened.workspaces.filter(recent => {
@@ -105,10 +108,10 @@ let BrowserWorkspacesService = class BrowserWorkspacesService extends Disposable
105
108
  });
106
109
  }
107
110
  async saveRecentlyOpened(data) {
108
- return this.storageService.store(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, JSON.stringify(toStoreData(data)), -1 , 0 );
111
+ return this.storageService.store(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, JSON.stringify(toStoreData(data)), StorageScope.APPLICATION, StorageTarget.USER);
109
112
  }
110
113
  async clearRecentlyOpened() {
111
- this.storageService.remove(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, -1 );
114
+ this.storageService.remove(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, StorageScope.APPLICATION);
112
115
  }
113
116
  async enterWorkspace(workspaceUri) {
114
117
  return { workspace: await this.getWorkspaceIdentifier(workspaceUri) };
@@ -131,7 +134,7 @@ let BrowserWorkspacesService = class BrowserWorkspacesService extends Disposable
131
134
  await this.fileService.del(workspace.configPath);
132
135
  }
133
136
  catch (error) {
134
- if (error.fileOperationResult !== 1 ) {
137
+ if (error.fileOperationResult !== FileOperationResult.FILE_NOT_FOUND) {
135
138
  throw error;
136
139
  }
137
140
  }