@codingame/monaco-vscode-configuration-service-override 4.0.0 → 4.1.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,337 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
- import { WORKSPACE_FILTER, hasWorkspaceFileExtension, WORKSPACE_EXTENSION, isSavedWorkspace, isUntitledWorkspace, toWorkspaceIdentifier, isWorkspaceIdentifier, IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
4
- import { IJSONEditingService } from 'vscode/vscode/vs/workbench/services/configuration/common/jsonEditing';
5
- import { rewriteWorkspaceFileForNewLocation, IWorkspacesService } from 'vscode/vscode/vs/platform/workspaces/common/workspaces';
6
- import { Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
7
- import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
8
- import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
9
- import { firstOrDefault, distinct } from 'vscode/vscode/vs/base/common/arrays';
10
- import { joinPath, basename, removeTrailingPathSeparator, isEqual } from 'vscode/vscode/vs/base/common/resources';
11
- import { Severity, INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
12
- import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
13
- import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService';
14
- import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
15
- import { mnemonicButtonLabel } from 'vscode/vscode/vs/base/common/labels';
16
- import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
17
- import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host';
18
- import { Schemas } from 'vscode/vscode/vs/base/common/network';
19
- import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
20
- import { IWorkspaceTrustManagementService } from 'vscode/vscode/vs/platform/workspace/common/workspaceTrust';
21
- import { IWorkbenchConfigurationService } from 'vscode/vscode/vs/workbench/services/configuration/common/configuration';
22
- import { IUserDataProfilesService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile';
23
- import { IUserDataProfileService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile';
24
- import { IFileDialogService, IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
25
-
26
- let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService {
27
- constructor(jsonEditingService, contextService, configurationService, notificationService, commandService, fileService, textFileService, workspacesService, environmentService, fileDialogService, dialogService, hostService, uriIdentityService, workspaceTrustManagementService, userDataProfilesService, userDataProfileService) {
28
- this.jsonEditingService = jsonEditingService;
29
- this.contextService = contextService;
30
- this.configurationService = configurationService;
31
- this.notificationService = notificationService;
32
- this.commandService = commandService;
33
- this.fileService = fileService;
34
- this.textFileService = textFileService;
35
- this.workspacesService = workspacesService;
36
- this.environmentService = environmentService;
37
- this.fileDialogService = fileDialogService;
38
- this.dialogService = dialogService;
39
- this.hostService = hostService;
40
- this.uriIdentityService = uriIdentityService;
41
- this.workspaceTrustManagementService = workspaceTrustManagementService;
42
- this.userDataProfilesService = userDataProfilesService;
43
- this.userDataProfileService = userDataProfileService;
44
- }
45
- async pickNewWorkspacePath() {
46
- const availableFileSystems = [Schemas.file];
47
- if (this.environmentService.remoteAuthority) {
48
- availableFileSystems.unshift(Schemas.vscodeRemote);
49
- }
50
- let workspacePath = await this.fileDialogService.showSaveDialog({
51
- saveLabel: mnemonicButtonLabel(( localizeWithPath(
52
- 'vs/workbench/services/workspaces/browser/abstractWorkspaceEditingService',
53
- 'save',
54
- "Save"
55
- ))),
56
- title: ( localizeWithPath(
57
- 'vs/workbench/services/workspaces/browser/abstractWorkspaceEditingService',
58
- 'saveWorkspace',
59
- "Save Workspace"
60
- )),
61
- filters: WORKSPACE_FILTER,
62
- defaultUri: joinPath(await this.fileDialogService.defaultWorkspacePath(), this.getNewWorkspaceName()),
63
- availableFileSystems
64
- });
65
- if (!workspacePath) {
66
- return;
67
- }
68
- if (!hasWorkspaceFileExtension(workspacePath)) {
69
- workspacePath = workspacePath.with({ path: `${workspacePath.path}.${WORKSPACE_EXTENSION}` });
70
- }
71
- return workspacePath;
72
- }
73
- getNewWorkspaceName() {
74
- const configPathURI = this.getCurrentWorkspaceIdentifier()?.configPath;
75
- if (configPathURI && isSavedWorkspace(configPathURI, this.environmentService)) {
76
- return basename(configPathURI);
77
- }
78
- const folder = firstOrDefault(this.contextService.getWorkspace().folders);
79
- if (folder) {
80
- return `${basename(folder.uri)}.${WORKSPACE_EXTENSION}`;
81
- }
82
- return `workspace.${WORKSPACE_EXTENSION}`;
83
- }
84
- async updateFolders(index, deleteCount, foldersToAddCandidates, donotNotifyError) {
85
- const folders = this.contextService.getWorkspace().folders;
86
- let foldersToDelete = [];
87
- if (typeof deleteCount === 'number') {
88
- foldersToDelete = ( folders.slice(index, index + deleteCount).map(folder => folder.uri));
89
- }
90
- let foldersToAdd = [];
91
- if (Array.isArray(foldersToAddCandidates)) {
92
- foldersToAdd = ( foldersToAddCandidates.map(
93
- folderToAdd => ({ uri: removeTrailingPathSeparator(folderToAdd.uri), name: folderToAdd.name })
94
- ));
95
- }
96
- const wantsToDelete = foldersToDelete.length > 0;
97
- const wantsToAdd = foldersToAdd.length > 0;
98
- if (!wantsToAdd && !wantsToDelete) {
99
- return;
100
- }
101
- if (wantsToAdd && !wantsToDelete) {
102
- return this.doAddFolders(foldersToAdd, index, donotNotifyError);
103
- }
104
- if (wantsToDelete && !wantsToAdd) {
105
- return this.removeFolders(foldersToDelete);
106
- }
107
- else {
108
- if (this.includesSingleFolderWorkspace(foldersToDelete)) {
109
- return this.createAndEnterWorkspace(foldersToAdd);
110
- }
111
- if (this.contextService.getWorkbenchState() !== 3 ) {
112
- return this.doAddFolders(foldersToAdd, index, donotNotifyError);
113
- }
114
- return this.doUpdateFolders(foldersToAdd, foldersToDelete, index, donotNotifyError);
115
- }
116
- }
117
- async doUpdateFolders(foldersToAdd, foldersToDelete, index, donotNotifyError = false) {
118
- try {
119
- await this.contextService.updateFolders(foldersToAdd, foldersToDelete, index);
120
- }
121
- catch (error) {
122
- if (donotNotifyError) {
123
- throw error;
124
- }
125
- this.handleWorkspaceConfigurationEditingError(error);
126
- }
127
- }
128
- addFolders(foldersToAddCandidates, donotNotifyError = false) {
129
- const foldersToAdd = ( foldersToAddCandidates.map(
130
- folderToAdd => ({ uri: removeTrailingPathSeparator(folderToAdd.uri), name: folderToAdd.name })
131
- ));
132
- return this.doAddFolders(foldersToAdd, undefined, donotNotifyError);
133
- }
134
- async doAddFolders(foldersToAdd, index, donotNotifyError = false) {
135
- const state = this.contextService.getWorkbenchState();
136
- if (state !== 3 ) {
137
- let newWorkspaceFolders = ( this.contextService.getWorkspace().folders.map(folder => ({ uri: folder.uri })));
138
- newWorkspaceFolders.splice(typeof index === 'number' ? index : newWorkspaceFolders.length, 0, ...foldersToAdd);
139
- newWorkspaceFolders = distinct(newWorkspaceFolders, folder => this.uriIdentityService.extUri.getComparisonKey(folder.uri));
140
- if (state === 1 && newWorkspaceFolders.length === 0 || state === 2 && newWorkspaceFolders.length === 1) {
141
- return;
142
- }
143
- return this.createAndEnterWorkspace(newWorkspaceFolders);
144
- }
145
- try {
146
- await this.contextService.addFolders(foldersToAdd, index);
147
- }
148
- catch (error) {
149
- if (donotNotifyError) {
150
- throw error;
151
- }
152
- this.handleWorkspaceConfigurationEditingError(error);
153
- }
154
- }
155
- async removeFolders(foldersToRemove, donotNotifyError = false) {
156
- if (this.includesSingleFolderWorkspace(foldersToRemove)) {
157
- return this.createAndEnterWorkspace([]);
158
- }
159
- try {
160
- await this.contextService.removeFolders(foldersToRemove);
161
- }
162
- catch (error) {
163
- if (donotNotifyError) {
164
- throw error;
165
- }
166
- this.handleWorkspaceConfigurationEditingError(error);
167
- }
168
- }
169
- includesSingleFolderWorkspace(folders) {
170
- if (this.contextService.getWorkbenchState() === 2 ) {
171
- const workspaceFolder = this.contextService.getWorkspace().folders[0];
172
- return ( folders.some(
173
- folder => this.uriIdentityService.extUri.isEqual(folder, workspaceFolder.uri)
174
- ));
175
- }
176
- return false;
177
- }
178
- async createAndEnterWorkspace(folders, path) {
179
- if (path && !(await this.isValidTargetWorkspacePath(path))) {
180
- return;
181
- }
182
- const remoteAuthority = this.environmentService.remoteAuthority;
183
- const untitledWorkspace = await this.workspacesService.createUntitledWorkspace(folders, remoteAuthority);
184
- if (path) {
185
- try {
186
- await this.saveWorkspaceAs(untitledWorkspace, path);
187
- }
188
- finally {
189
- await this.workspacesService.deleteUntitledWorkspace(untitledWorkspace);
190
- }
191
- }
192
- else {
193
- path = untitledWorkspace.configPath;
194
- if (!this.userDataProfileService.currentProfile.isDefault) {
195
- await this.userDataProfilesService.setProfileForWorkspace(untitledWorkspace, this.userDataProfileService.currentProfile);
196
- }
197
- }
198
- return this.enterWorkspace(path);
199
- }
200
- async saveAndEnterWorkspace(workspaceUri) {
201
- const workspaceIdentifier = this.getCurrentWorkspaceIdentifier();
202
- if (!workspaceIdentifier) {
203
- return;
204
- }
205
- if (isEqual(workspaceIdentifier.configPath, workspaceUri)) {
206
- return this.saveWorkspace(workspaceIdentifier);
207
- }
208
- if (!(await this.isValidTargetWorkspacePath(workspaceUri))) {
209
- return;
210
- }
211
- await this.saveWorkspaceAs(workspaceIdentifier, workspaceUri);
212
- return this.enterWorkspace(workspaceUri);
213
- }
214
- async isValidTargetWorkspacePath(workspaceUri) {
215
- return true;
216
- }
217
- async saveWorkspaceAs(workspace, targetConfigPathURI) {
218
- const configPathURI = workspace.configPath;
219
- const isNotUntitledWorkspace = !isUntitledWorkspace(targetConfigPathURI, this.environmentService);
220
- if (isNotUntitledWorkspace && !this.userDataProfileService.currentProfile.isDefault) {
221
- const newWorkspace = await this.workspacesService.getWorkspaceIdentifier(targetConfigPathURI);
222
- await this.userDataProfilesService.setProfileForWorkspace(newWorkspace, this.userDataProfileService.currentProfile);
223
- }
224
- if (this.uriIdentityService.extUri.isEqual(configPathURI, targetConfigPathURI)) {
225
- return;
226
- }
227
- const isFromUntitledWorkspace = isUntitledWorkspace(configPathURI, this.environmentService);
228
- const raw = await this.fileService.readFile(configPathURI);
229
- const newRawWorkspaceContents = rewriteWorkspaceFileForNewLocation(( raw.value.toString()), configPathURI, isFromUntitledWorkspace, targetConfigPathURI, this.uriIdentityService.extUri);
230
- await this.textFileService.create([{ resource: targetConfigPathURI, value: newRawWorkspaceContents, options: { overwrite: true } }]);
231
- await this.trustWorkspaceConfiguration(targetConfigPathURI);
232
- }
233
- async saveWorkspace(workspace) {
234
- const configPathURI = workspace.configPath;
235
- const existingModel = this.textFileService.files.get(configPathURI);
236
- if (existingModel) {
237
- await existingModel.save({ force: true, reason: 1 });
238
- return;
239
- }
240
- const workspaceFileExists = await this.fileService.exists(configPathURI);
241
- if (workspaceFileExists) {
242
- return;
243
- }
244
- const newWorkspace = { folders: [] };
245
- const newRawWorkspaceContents = rewriteWorkspaceFileForNewLocation(JSON.stringify(newWorkspace, null, '\t'), configPathURI, false, configPathURI, this.uriIdentityService.extUri);
246
- await this.textFileService.create([{ resource: configPathURI, value: newRawWorkspaceContents }]);
247
- }
248
- handleWorkspaceConfigurationEditingError(error) {
249
- switch (error.code) {
250
- case 0 :
251
- this.onInvalidWorkspaceConfigurationFileError();
252
- break;
253
- default:
254
- this.notificationService.error(error.message);
255
- }
256
- }
257
- onInvalidWorkspaceConfigurationFileError() {
258
- const message = ( localizeWithPath(
259
- 'vs/workbench/services/workspaces/browser/abstractWorkspaceEditingService',
260
- 'errorInvalidTaskConfiguration',
261
- "Unable to write into workspace configuration file. Please open the file to correct errors/warnings in it and try again."
262
- ));
263
- this.askToOpenWorkspaceConfigurationFile(message);
264
- }
265
- askToOpenWorkspaceConfigurationFile(message) {
266
- this.notificationService.prompt(Severity.Error, message, [{
267
- label: ( localizeWithPath(
268
- 'vs/workbench/services/workspaces/browser/abstractWorkspaceEditingService',
269
- 'openWorkspaceConfigurationFile',
270
- "Open Workspace Configuration"
271
- )),
272
- run: () => this.commandService.executeCommand('workbench.action.openWorkspaceConfigFile')
273
- }]);
274
- }
275
- async doEnterWorkspace(workspaceUri) {
276
- if (!!this.environmentService.extensionTestsLocationURI) {
277
- throw new Error('Entering a new workspace is not possible in tests.');
278
- }
279
- const workspace = await this.workspacesService.getWorkspaceIdentifier(workspaceUri);
280
- if (this.contextService.getWorkbenchState() === 2 ) {
281
- await this.migrateWorkspaceSettings(workspace);
282
- }
283
- await this.configurationService.initialize(workspace);
284
- return this.workspacesService.enterWorkspace(workspaceUri);
285
- }
286
- migrateWorkspaceSettings(toWorkspace) {
287
- return this.doCopyWorkspaceSettings(toWorkspace, setting => setting.scope === 3 );
288
- }
289
- copyWorkspaceSettings(toWorkspace) {
290
- return this.doCopyWorkspaceSettings(toWorkspace);
291
- }
292
- doCopyWorkspaceSettings(toWorkspace, filter) {
293
- const configurationProperties = ( Registry.as(Extensions.Configuration)).getConfigurationProperties();
294
- const targetWorkspaceConfiguration = {};
295
- for (const key of ( this.configurationService.keys()).workspace) {
296
- if (configurationProperties[key]) {
297
- if (filter && !filter(configurationProperties[key])) {
298
- continue;
299
- }
300
- targetWorkspaceConfiguration[key] = this.configurationService.inspect(key).workspaceValue;
301
- }
302
- }
303
- return this.jsonEditingService.write(toWorkspace.configPath, [{ path: ['settings'], value: targetWorkspaceConfiguration }], true);
304
- }
305
- async trustWorkspaceConfiguration(configPathURI) {
306
- if (this.contextService.getWorkbenchState() !== 1 && this.workspaceTrustManagementService.isWorkspaceTrusted()) {
307
- await this.workspaceTrustManagementService.setUrisTrust([configPathURI], true);
308
- }
309
- }
310
- getCurrentWorkspaceIdentifier() {
311
- const identifier = toWorkspaceIdentifier(this.contextService.getWorkspace());
312
- if (isWorkspaceIdentifier(identifier)) {
313
- return identifier;
314
- }
315
- return undefined;
316
- }
317
- };
318
- AbstractWorkspaceEditingService = ( __decorate([
319
- ( __param(0, IJSONEditingService)),
320
- ( __param(1, IWorkspaceContextService)),
321
- ( __param(2, IWorkbenchConfigurationService)),
322
- ( __param(3, INotificationService)),
323
- ( __param(4, ICommandService)),
324
- ( __param(5, IFileService)),
325
- ( __param(6, ITextFileService)),
326
- ( __param(7, IWorkspacesService)),
327
- ( __param(8, IWorkbenchEnvironmentService)),
328
- ( __param(9, IFileDialogService)),
329
- ( __param(10, IDialogService)),
330
- ( __param(11, IHostService)),
331
- ( __param(12, IUriIdentityService)),
332
- ( __param(13, IWorkspaceTrustManagementService)),
333
- ( __param(14, IUserDataProfilesService)),
334
- ( __param(15, IUserDataProfileService))
335
- ], AbstractWorkspaceEditingService));
336
-
337
- export { AbstractWorkspaceEditingService };
@@ -1,153 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { restoreRecentlyOpened, isRecentFolder, isRecentWorkspace, isRecentFile, toStoreData, getStoredWorkspaceFolder } from 'vscode/vscode/vs/platform/workspaces/common/workspaces';
3
- import { Emitter } from 'vscode/vscode/vs/base/common/event';
4
- import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
5
- import { isTemporaryWorkspace, WORKSPACE_EXTENSION, IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
6
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
7
- import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
8
- import { getWorkspaceIdentifier } from 'vscode/vscode/vs/workbench/services/workspaces/browser/workspaces';
9
- import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
10
- import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService';
11
- import { joinPath } from 'vscode/vscode/vs/base/common/resources';
12
- import { VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
13
- import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
14
- import { Schemas } from 'vscode/vscode/vs/base/common/network';
15
-
16
- var BrowserWorkspacesService_1;
17
- let BrowserWorkspacesService = class BrowserWorkspacesService extends Disposable {
18
- static { BrowserWorkspacesService_1 = this; }
19
- static { this.RECENTLY_OPENED_KEY = 'recently.opened'; }
20
- constructor(storageService, contextService, logService, fileService, environmentService, uriIdentityService) {
21
- super();
22
- this.storageService = storageService;
23
- this.contextService = contextService;
24
- this.logService = logService;
25
- this.fileService = fileService;
26
- this.environmentService = environmentService;
27
- this.uriIdentityService = uriIdentityService;
28
- this._onRecentlyOpenedChange = this._register(( new Emitter()));
29
- this.onDidChangeRecentlyOpened = this._onRecentlyOpenedChange.event;
30
- this.addWorkspaceToRecentlyOpened();
31
- this.registerListeners();
32
- }
33
- registerListeners() {
34
- this._register(this.storageService.onDidChangeValue(-1 , BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, this._register(( new DisposableStore())))(() => this._onRecentlyOpenedChange.fire()));
35
- this._register(this.contextService.onDidChangeWorkspaceFolders(e => this.onDidChangeWorkspaceFolders(e)));
36
- }
37
- onDidChangeWorkspaceFolders(e) {
38
- if (!isTemporaryWorkspace(this.contextService.getWorkspace())) {
39
- return;
40
- }
41
- for (const folder of e.added) {
42
- this.addRecentlyOpened([{ folderUri: folder.uri }]);
43
- }
44
- }
45
- addWorkspaceToRecentlyOpened() {
46
- const workspace = this.contextService.getWorkspace();
47
- const remoteAuthority = this.environmentService.remoteAuthority;
48
- switch (this.contextService.getWorkbenchState()) {
49
- case 2 :
50
- this.addRecentlyOpened([{ folderUri: workspace.folders[0].uri, remoteAuthority }]);
51
- break;
52
- case 3 :
53
- this.addRecentlyOpened([{ workspace: { id: workspace.id, configPath: workspace.configuration }, remoteAuthority }]);
54
- break;
55
- }
56
- }
57
- async getRecentlyOpened() {
58
- const recentlyOpenedRaw = this.storageService.get(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, -1 );
59
- if (recentlyOpenedRaw) {
60
- const recentlyOpened = restoreRecentlyOpened(JSON.parse(recentlyOpenedRaw), this.logService);
61
- recentlyOpened.workspaces = recentlyOpened.workspaces.filter(recent => {
62
- if (isRecentFolder(recent) && recent.folderUri.scheme === Schemas.file && !isTemporaryWorkspace(this.contextService.getWorkspace())) {
63
- return false;
64
- }
65
- if (isRecentWorkspace(recent) && isTemporaryWorkspace(recent.workspace.configPath)) {
66
- return false;
67
- }
68
- return true;
69
- });
70
- return recentlyOpened;
71
- }
72
- return { workspaces: [], files: [] };
73
- }
74
- async addRecentlyOpened(recents) {
75
- const recentlyOpened = await this.getRecentlyOpened();
76
- for (const recent of recents) {
77
- if (isRecentFile(recent)) {
78
- this.doRemoveRecentlyOpened(recentlyOpened, [recent.fileUri]);
79
- recentlyOpened.files.unshift(recent);
80
- }
81
- else if (isRecentFolder(recent)) {
82
- this.doRemoveRecentlyOpened(recentlyOpened, [recent.folderUri]);
83
- recentlyOpened.workspaces.unshift(recent);
84
- }
85
- else {
86
- this.doRemoveRecentlyOpened(recentlyOpened, [recent.workspace.configPath]);
87
- recentlyOpened.workspaces.unshift(recent);
88
- }
89
- }
90
- return this.saveRecentlyOpened(recentlyOpened);
91
- }
92
- async removeRecentlyOpened(paths) {
93
- const recentlyOpened = await this.getRecentlyOpened();
94
- this.doRemoveRecentlyOpened(recentlyOpened, paths);
95
- return this.saveRecentlyOpened(recentlyOpened);
96
- }
97
- doRemoveRecentlyOpened(recentlyOpened, paths) {
98
- recentlyOpened.files = recentlyOpened.files.filter(file => {
99
- return !( paths.some(path => ( path.toString()) === ( file.fileUri.toString())));
100
- });
101
- recentlyOpened.workspaces = recentlyOpened.workspaces.filter(workspace => {
102
- return !( paths.some(path => ( path.toString()) === (isRecentFolder(workspace) ? ( workspace.folderUri.toString()) : ( workspace.workspace.configPath.toString()))));
103
- });
104
- }
105
- async saveRecentlyOpened(data) {
106
- return this.storageService.store(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, JSON.stringify(toStoreData(data)), -1 , 0 );
107
- }
108
- async clearRecentlyOpened() {
109
- this.storageService.remove(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, -1 );
110
- }
111
- async enterWorkspace(workspaceUri) {
112
- return { workspace: await this.getWorkspaceIdentifier(workspaceUri) };
113
- }
114
- async createUntitledWorkspace(folders, remoteAuthority) {
115
- const randomId = ( (Date.now() + Math.round(Math.random() * 1000)).toString());
116
- const newUntitledWorkspacePath = joinPath(this.environmentService.untitledWorkspacesHome, `Untitled-${randomId}.${WORKSPACE_EXTENSION}`);
117
- const storedWorkspaceFolder = [];
118
- if (folders) {
119
- for (const folder of folders) {
120
- storedWorkspaceFolder.push(getStoredWorkspaceFolder(folder.uri, true, folder.name, this.environmentService.untitledWorkspacesHome, this.uriIdentityService.extUri));
121
- }
122
- }
123
- const storedWorkspace = { folders: storedWorkspaceFolder, remoteAuthority };
124
- await this.fileService.writeFile(newUntitledWorkspacePath, VSBuffer.fromString(JSON.stringify(storedWorkspace, null, '\t')));
125
- return this.getWorkspaceIdentifier(newUntitledWorkspacePath);
126
- }
127
- async deleteUntitledWorkspace(workspace) {
128
- try {
129
- await this.fileService.del(workspace.configPath);
130
- }
131
- catch (error) {
132
- if (error.fileOperationResult !== 1 ) {
133
- throw error;
134
- }
135
- }
136
- }
137
- async getWorkspaceIdentifier(workspaceUri) {
138
- return getWorkspaceIdentifier(workspaceUri);
139
- }
140
- async getDirtyWorkspaces() {
141
- return [];
142
- }
143
- };
144
- BrowserWorkspacesService = BrowserWorkspacesService_1 = ( __decorate([
145
- ( __param(0, IStorageService)),
146
- ( __param(1, IWorkspaceContextService)),
147
- ( __param(2, ILogService)),
148
- ( __param(3, IFileService)),
149
- ( __param(4, IWorkbenchEnvironmentService)),
150
- ( __param(5, IUriIdentityService))
151
- ], BrowserWorkspacesService));
152
-
153
- export { BrowserWorkspacesService };