@codingame/monaco-vscode-api 1.69.24 → 1.76.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/dist/_.contribution.js +3 -3
- package/dist/api.js +63 -31
- package/dist/async.js +9 -9
- package/dist/configuration.d.ts +109 -21
- package/dist/configuration.js +47 -217
- package/dist/{workspace.js → contextkey.js} +26 -47
- package/dist/dialogs.js +498 -426
- package/dist/extHost.js +1884 -909
- package/dist/files.js +65 -63
- package/dist/keybindings.d.ts +24 -18
- package/dist/keybindings.js +475 -404
- package/dist/languageConfiguration.js +5 -5
- package/dist/languageService.js +11 -3
- package/dist/languages.d.ts +24 -7
- package/dist/languages.js +1 -1
- package/dist/layout.js +104 -166
- package/dist/missing-services.js +230 -77
- package/dist/modelEditor.d.ts +1 -5
- package/dist/modelEditor.js +32 -58
- package/dist/monaco.d.ts +303 -713
- package/dist/monaco.js +2 -2
- package/dist/notifications.js +95 -235
- package/dist/polyfill.js +2022 -1637
- package/dist/services.d.ts +8908 -8467
- package/dist/services.js +1 -1
- package/dist/services2.js +293 -113
- package/dist/snippets.d.ts +24 -7
- package/dist/snippets.js +11 -9
- package/dist/textmate.d.ts +114 -20
- package/dist/textmate.js +825 -453
- package/dist/theme.js +13 -14
- package/dist/tokenClassification.d.ts +24 -7
- package/dist/tokenClassification.js +1 -1
- package/dist/tokenClassificationRegistry.js +1 -1
- package/dist/tools.js +104 -28
- package/package.json +12 -19
- package/dist/messages.d.ts +0 -10
- package/dist/messages.js +0 -11
- package/dist/types.js +0 -46
package/dist/services.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { I as IEditorGroupsService, b as IEditorService, c as IFileService, d as IHostService, e as ILanguageStatusService, f as IPaneCompositePartService, g as IPathService, h as IProductService, i as ISnippetsService, j as ITextFileService, k as IUriIdentityService, l as IWorkbenchEnvironmentService, m as IWorkingCopyFileService, S as Services, n as StorageScope, o as StorageTarget } from './services2.js';
|
|
2
|
-
export { C as ContextKeyExprType, N as NotificationsFilter } from './
|
|
2
|
+
export { C as ContextKeyExprType, N as NotificationsFilter } from './contextkey.js';
|
|
3
3
|
export { StandaloneServices } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js';
|
|
4
4
|
export { ICommandService } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
|
|
5
5
|
export { INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
|
package/dist/services2.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { createDecorator } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
2
2
|
import { IEnvironmentService } from 'monaco-editor/esm/vs/platform/environment/common/environment.js';
|
|
3
|
-
import { _ as __decorate, E as Emitter,
|
|
4
|
-
import { ResourceMap, TernarySearchTree } from 'monaco-editor/esm/vs/base/common/map.js';
|
|
3
|
+
import { _ as __decorate, E as Emitter, a as __param } from './contextkey.js';
|
|
5
4
|
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
5
|
+
import { TernarySearchTree } from 'monaco-editor/esm/vs/base/common/ternarySearchTree.js';
|
|
6
6
|
import { Disposable, MutableDisposable, dispose } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { ResourceMap } from 'monaco-editor/esm/vs/base/common/map.js';
|
|
8
|
+
import { joinPath, basename } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
9
|
+
import { isString, isUndefinedOrNull } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
10
|
+
import { escapeRegExpCharacters } from 'monaco-editor/esm/vs/base/common/strings.js';
|
|
10
11
|
import { hash } from 'monaco-editor/esm/vs/base/common/hash.js';
|
|
11
12
|
import { generateUuid } from 'monaco-editor/esm/vs/base/common/uuid.js';
|
|
12
13
|
import { Promises, RunOnceScheduler, runWhenIdle } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
14
|
+
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
15
|
+
import { isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
|
|
13
16
|
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
14
|
-
import { isUndefinedOrNull, isUndefined } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
15
17
|
import { PauseableEmitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
16
18
|
function refineServiceDecorator(serviceIdentifier) {
|
|
17
19
|
return serviceIdentifier;
|
|
@@ -63,15 +65,18 @@ var FileSystemProviderErrorCode;
|
|
|
63
65
|
FileSystemProviderErrorCode["Unknown"] = "Unknown";
|
|
64
66
|
})(FileSystemProviderErrorCode || (FileSystemProviderErrorCode = {}))));
|
|
65
67
|
class FileSystemProviderError extends Error {
|
|
68
|
+
static create(error, code) {
|
|
69
|
+
const providerError = ( (new FileSystemProviderError( (error.toString()), code)));
|
|
70
|
+
markAsFileSystemProviderError(providerError, code);
|
|
71
|
+
return providerError;
|
|
72
|
+
}
|
|
66
73
|
constructor(message, code) {
|
|
67
74
|
super(message);
|
|
68
75
|
this.code = code;
|
|
69
76
|
}
|
|
70
77
|
}
|
|
71
78
|
function createFileSystemProviderError(error, code) {
|
|
72
|
-
|
|
73
|
-
markAsFileSystemProviderError(providerError, code);
|
|
74
|
-
return providerError;
|
|
79
|
+
return FileSystemProviderError.create(error, code);
|
|
75
80
|
}
|
|
76
81
|
function ensureFileSystemProviderError(error) {
|
|
77
82
|
if (!error) {
|
|
@@ -147,11 +152,9 @@ class FileChangesEvent {
|
|
|
147
152
|
this.added = undefined;
|
|
148
153
|
this.updated = undefined;
|
|
149
154
|
this.deleted = undefined;
|
|
150
|
-
this.rawChanges = [];
|
|
151
155
|
this.rawAdded = [];
|
|
152
156
|
this.rawUpdated = [];
|
|
153
157
|
this.rawDeleted = [];
|
|
154
|
-
this.rawChanges = changes;
|
|
155
158
|
const entriesByType = ( (new Map()));
|
|
156
159
|
for (const change of changes) {
|
|
157
160
|
const array = entriesByType.get(change.type);
|
|
@@ -244,6 +247,13 @@ class FileOperationError extends Error {
|
|
|
244
247
|
this.options = options;
|
|
245
248
|
}
|
|
246
249
|
}
|
|
250
|
+
class TooLargeFileOperationError extends FileOperationError {
|
|
251
|
+
constructor(message, fileOperationResult, size, options) {
|
|
252
|
+
super(message, fileOperationResult, options);
|
|
253
|
+
this.fileOperationResult = fileOperationResult;
|
|
254
|
+
this.size = size;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
247
257
|
class NotModifiedSinceFileOperationError extends FileOperationError {
|
|
248
258
|
constructor(message, stat, options) {
|
|
249
259
|
super(message, 2 , options);
|
|
@@ -271,147 +281,190 @@ function isUserDataProfile(thing) {
|
|
|
271
281
|
&& URI.isUri(candidate.keybindingsResource)
|
|
272
282
|
&& URI.isUri(candidate.tasksResource)
|
|
273
283
|
&& URI.isUri(candidate.snippetsHome)
|
|
274
|
-
&&
|
|
284
|
+
&& URI.isUri(candidate.extensionsResource));
|
|
275
285
|
}
|
|
276
|
-
const PROFILES_ENABLEMENT_CONFIG = 'workbench.experimental.settingsProfiles.enabled';
|
|
277
286
|
const IUserDataProfilesService = ( (createDecorator('IUserDataProfilesService')));
|
|
278
|
-
|
|
279
|
-
function toUserDataProfile(name, location, useDefaultFlags) {
|
|
287
|
+
function toUserDataProfile(id, name, location, options) {
|
|
280
288
|
return {
|
|
281
|
-
id
|
|
282
|
-
name
|
|
283
|
-
location
|
|
289
|
+
id,
|
|
290
|
+
name,
|
|
291
|
+
location,
|
|
284
292
|
isDefault: false,
|
|
293
|
+
shortName: options?.shortName,
|
|
285
294
|
globalStorageHome: joinPath(location, 'globalStorage'),
|
|
286
295
|
settingsResource: joinPath(location, 'settings.json'),
|
|
287
296
|
keybindingsResource: joinPath(location, 'keybindings.json'),
|
|
288
297
|
tasksResource: joinPath(location, 'tasks.json'),
|
|
289
298
|
snippetsHome: joinPath(location, 'snippets'),
|
|
290
|
-
extensionsResource: joinPath(location,
|
|
291
|
-
useDefaultFlags
|
|
299
|
+
extensionsResource: joinPath(location, 'extensions.json'),
|
|
300
|
+
useDefaultFlags: options?.useDefaultFlags,
|
|
301
|
+
isTransient: options?.transient
|
|
292
302
|
};
|
|
293
303
|
}
|
|
294
304
|
let UserDataProfilesService = class UserDataProfilesService extends Disposable {
|
|
305
|
+
get defaultProfile() { return this.profiles[0]; }
|
|
306
|
+
get profiles() { return [...this.profilesObject.profiles, ...this.transientProfilesObject.profiles]; }
|
|
295
307
|
constructor(environmentService, fileService, uriIdentityService, logService) {
|
|
296
308
|
super();
|
|
297
309
|
this.environmentService = environmentService;
|
|
298
310
|
this.fileService = fileService;
|
|
299
311
|
this.uriIdentityService = uriIdentityService;
|
|
300
312
|
this.logService = logService;
|
|
301
|
-
this.enabled =
|
|
302
|
-
this.defaultProfileShouldIncludeExtensionsResourceAlways = false;
|
|
313
|
+
this.enabled = true;
|
|
303
314
|
this._onDidChangeProfiles = this._register(( (new Emitter())));
|
|
304
315
|
this.onDidChangeProfiles = this._onDidChangeProfiles.event;
|
|
305
316
|
this._onWillCreateProfile = this._register(( (new Emitter())));
|
|
306
317
|
this.onWillCreateProfile = this._onWillCreateProfile.event;
|
|
307
318
|
this._onWillRemoveProfile = this._register(( (new Emitter())));
|
|
308
319
|
this.onWillRemoveProfile = this._onWillRemoveProfile.event;
|
|
320
|
+
this._onDidResetWorkspaces = this._register(( (new Emitter())));
|
|
321
|
+
this.onDidResetWorkspaces = this._onDidResetWorkspaces.event;
|
|
322
|
+
this.profileCreationPromises = ( (new Map()));
|
|
323
|
+
this.transientProfilesObject = {
|
|
324
|
+
profiles: [],
|
|
325
|
+
workspaces: ( (new ResourceMap())),
|
|
326
|
+
emptyWindows: ( (new Map()))
|
|
327
|
+
};
|
|
309
328
|
this.profilesHome = joinPath(this.environmentService.userRoamingDataHome, 'profiles');
|
|
310
329
|
}
|
|
311
|
-
|
|
312
|
-
|
|
330
|
+
init() {
|
|
331
|
+
this._profilesObject = undefined;
|
|
332
|
+
}
|
|
313
333
|
setEnablement(enabled) {
|
|
314
334
|
if (this.enabled !== enabled) {
|
|
315
335
|
this._profilesObject = undefined;
|
|
316
336
|
this.enabled = enabled;
|
|
317
337
|
}
|
|
318
338
|
}
|
|
339
|
+
isEnabled() {
|
|
340
|
+
return this.enabled;
|
|
341
|
+
}
|
|
319
342
|
get profilesObject() {
|
|
320
343
|
if (!this._profilesObject) {
|
|
321
|
-
const profiles =
|
|
322
|
-
|
|
344
|
+
const profiles = [];
|
|
345
|
+
if (this.enabled) {
|
|
346
|
+
try {
|
|
347
|
+
for (const storedProfile of this.getStoredProfiles()) {
|
|
348
|
+
if (!storedProfile.name || !isString(storedProfile.name) || !storedProfile.location) {
|
|
349
|
+
this.logService.warn('Skipping the invalid stored profile', storedProfile.location || storedProfile.name);
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
profiles.push(toUserDataProfile(basename(storedProfile.location), storedProfile.name, storedProfile.location, { shortName: storedProfile.shortName, useDefaultFlags: storedProfile.useDefaultFlags }));
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
catch (error) {
|
|
356
|
+
this.logService.error(error);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
323
359
|
const workspaces = ( (new ResourceMap()));
|
|
360
|
+
const emptyWindows = ( (new Map()));
|
|
361
|
+
const defaultProfile = this.createDefaultProfile();
|
|
362
|
+
profiles.unshift({ ...defaultProfile, extensionsResource: this.getDefaultProfileExtensionsLocation() ?? defaultProfile.extensionsResource, isDefault: true });
|
|
324
363
|
if (profiles.length) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
364
|
+
try {
|
|
365
|
+
const profileAssociaitions = this.getStoredProfileAssociations();
|
|
366
|
+
if (profileAssociaitions.workspaces) {
|
|
367
|
+
for (const [workspacePath, profileId] of Object.entries(profileAssociaitions.workspaces)) {
|
|
368
|
+
const workspace = ( (URI.parse(workspacePath)));
|
|
369
|
+
const profile = profiles.find(p => p.id === profileId);
|
|
370
|
+
if (profile) {
|
|
371
|
+
workspaces.set(workspace, profile);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (profileAssociaitions.emptyWindows) {
|
|
376
|
+
for (const [windowId, profileId] of Object.entries(profileAssociaitions.emptyWindows)) {
|
|
377
|
+
const profile = profiles.find(p => p.id === profileId);
|
|
378
|
+
if (profile) {
|
|
379
|
+
emptyWindows.set(windowId, profile);
|
|
380
|
+
}
|
|
333
381
|
}
|
|
334
382
|
}
|
|
335
383
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
emptyWindow = profiles.find(p => this.uriIdentityService.extUri.isEqual(p.location, emptyWindowProfileLocation));
|
|
384
|
+
catch (error) {
|
|
385
|
+
this.logService.error(error);
|
|
339
386
|
}
|
|
340
387
|
}
|
|
341
|
-
|
|
342
|
-
profiles.unshift({ ...profile, isDefault: true, extensionsResource: this.defaultProfileShouldIncludeExtensionsResourceAlways || profiles.length > 0 ? profile.extensionsResource : undefined });
|
|
343
|
-
this._profilesObject = { profiles, workspaces, emptyWindow };
|
|
388
|
+
this._profilesObject = { profiles, workspaces, emptyWindows };
|
|
344
389
|
}
|
|
345
390
|
return this._profilesObject;
|
|
346
391
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
392
|
+
createDefaultProfile() {
|
|
393
|
+
return toUserDataProfile('__default__profile__', ( (localize('defaultProfile', "Default"))), this.environmentService.userRoamingDataHome);
|
|
394
|
+
}
|
|
395
|
+
async createTransientProfile(workspaceIdentifier) {
|
|
396
|
+
const namePrefix = `Temp`;
|
|
397
|
+
const nameRegEx = ( (new RegExp(`${escapeRegExpCharacters(namePrefix)}\\s(\\d+)`)));
|
|
398
|
+
let nameIndex = 0;
|
|
399
|
+
for (const profile of this.profiles) {
|
|
400
|
+
const matches = nameRegEx.exec(profile.name);
|
|
401
|
+
const index = matches ? parseInt(matches[1]) : 0;
|
|
402
|
+
nameIndex = index > nameIndex ? index : nameIndex;
|
|
358
403
|
}
|
|
359
|
-
|
|
404
|
+
const name = `${namePrefix} ${nameIndex + 1}`;
|
|
405
|
+
return this.createProfile(( (hash(generateUuid()).toString(16))), name, { transient: true }, workspaceIdentifier);
|
|
406
|
+
}
|
|
407
|
+
async createNamedProfile(name, options, workspaceIdentifier) {
|
|
408
|
+
return this.createProfile(( (hash(generateUuid()).toString(16))), name, options, workspaceIdentifier);
|
|
360
409
|
}
|
|
361
|
-
async createProfile(name,
|
|
410
|
+
async createProfile(id, name, options, workspaceIdentifier) {
|
|
362
411
|
if (!this.enabled) {
|
|
363
|
-
throw new Error(`
|
|
412
|
+
throw new Error(`Profiles are disabled in the current environment.`);
|
|
364
413
|
}
|
|
365
|
-
|
|
366
|
-
throw new Error(`Profile with name ${name} already exists`);
|
|
367
|
-
}
|
|
368
|
-
const profile = toUserDataProfile(name, joinPath(this.profilesHome, ( (hash(generateUuid()).toString(16)))), useDefaultFlags);
|
|
369
|
-
await this.fileService.createFolder(profile.location);
|
|
370
|
-
const joiners = [];
|
|
371
|
-
this._onWillCreateProfile.fire({
|
|
372
|
-
profile,
|
|
373
|
-
join(promise) {
|
|
374
|
-
joiners.push(promise);
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
await Promises.settled(joiners);
|
|
378
|
-
this.updateProfiles([profile], [], []);
|
|
414
|
+
const profile = await this.doCreateProfile(id, name, options);
|
|
379
415
|
if (workspaceIdentifier) {
|
|
380
|
-
await this.setProfileForWorkspace(
|
|
416
|
+
await this.setProfileForWorkspace(workspaceIdentifier, profile);
|
|
381
417
|
}
|
|
382
418
|
return profile;
|
|
383
419
|
}
|
|
384
|
-
async
|
|
420
|
+
async doCreateProfile(id, name, options) {
|
|
421
|
+
if (!isString(name) || !name) {
|
|
422
|
+
throw new Error('Name of the profile is mandatory and must be of type `string`');
|
|
423
|
+
}
|
|
424
|
+
let profileCreationPromise = this.profileCreationPromises.get(name);
|
|
425
|
+
if (!profileCreationPromise) {
|
|
426
|
+
profileCreationPromise = (async () => {
|
|
427
|
+
try {
|
|
428
|
+
const existing = this.profiles.find(p => p.name === name || p.id === id);
|
|
429
|
+
if (existing) {
|
|
430
|
+
return existing;
|
|
431
|
+
}
|
|
432
|
+
const profile = toUserDataProfile(id, name, joinPath(this.profilesHome, id), options);
|
|
433
|
+
await this.fileService.createFolder(profile.location);
|
|
434
|
+
const joiners = [];
|
|
435
|
+
this._onWillCreateProfile.fire({
|
|
436
|
+
profile,
|
|
437
|
+
join(promise) {
|
|
438
|
+
joiners.push(promise);
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
await Promises.settled(joiners);
|
|
442
|
+
this.updateProfiles([profile], [], []);
|
|
443
|
+
return profile;
|
|
444
|
+
}
|
|
445
|
+
finally {
|
|
446
|
+
this.profileCreationPromises.delete(name);
|
|
447
|
+
}
|
|
448
|
+
})();
|
|
449
|
+
this.profileCreationPromises.set(name, profileCreationPromise);
|
|
450
|
+
}
|
|
451
|
+
return profileCreationPromise;
|
|
452
|
+
}
|
|
453
|
+
async updateProfile(profileToUpdate, options) {
|
|
385
454
|
if (!this.enabled) {
|
|
386
|
-
throw new Error(`
|
|
455
|
+
throw new Error(`Profiles are disabled in the current environment.`);
|
|
387
456
|
}
|
|
388
457
|
let profile = this.profiles.find(p => p.id === profileToUpdate.id);
|
|
389
458
|
if (!profile) {
|
|
390
459
|
throw new Error(`Profile '${profileToUpdate.name}' does not exist`);
|
|
391
460
|
}
|
|
392
|
-
profile = toUserDataProfile(name, profile.location, useDefaultFlags);
|
|
461
|
+
profile = toUserDataProfile(profile.id, options.name ?? profile.name, profile.location, { shortName: options.shortName ?? profile.shortName, transient: options.transient ?? profile.isTransient, useDefaultFlags: options.useDefaultFlags ?? profile.useDefaultFlags });
|
|
393
462
|
this.updateProfiles([], [], [profile]);
|
|
394
463
|
return profile;
|
|
395
464
|
}
|
|
396
|
-
async setProfileForWorkspace(profileToSet, workspaceIdentifier) {
|
|
397
|
-
if (!this.enabled) {
|
|
398
|
-
throw new Error(`Settings Profiles are disabled. Enable them via the '${PROFILES_ENABLEMENT_CONFIG}' setting.`);
|
|
399
|
-
}
|
|
400
|
-
const profile = this.profiles.find(p => p.id === profileToSet.id);
|
|
401
|
-
if (!profile) {
|
|
402
|
-
throw new Error(`Profile '${profileToSet.name}' does not exist`);
|
|
403
|
-
}
|
|
404
|
-
this.updateWorkspaceAssociation(workspaceIdentifier, profile);
|
|
405
|
-
}
|
|
406
|
-
async unsetWorkspace(workspaceIdentifier) {
|
|
407
|
-
if (!this.enabled) {
|
|
408
|
-
throw new Error(`Settings Profiles are disabled. Enable them via the '${PROFILES_ENABLEMENT_CONFIG}' setting.`);
|
|
409
|
-
}
|
|
410
|
-
this.updateWorkspaceAssociation(workspaceIdentifier);
|
|
411
|
-
}
|
|
412
465
|
async removeProfile(profileToRemove) {
|
|
413
466
|
if (!this.enabled) {
|
|
414
|
-
throw new Error(`
|
|
467
|
+
throw new Error(`Profiles are disabled in the current environment.`);
|
|
415
468
|
}
|
|
416
469
|
if (profileToRemove.isDefault) {
|
|
417
470
|
throw new Error('Cannot remove default profile');
|
|
@@ -427,9 +480,16 @@ let UserDataProfilesService = class UserDataProfilesService extends Disposable {
|
|
|
427
480
|
joiners.push(promise);
|
|
428
481
|
}
|
|
429
482
|
});
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
483
|
+
try {
|
|
484
|
+
await Promise.allSettled(joiners);
|
|
485
|
+
}
|
|
486
|
+
catch (error) {
|
|
487
|
+
this.logService.error(error);
|
|
488
|
+
}
|
|
489
|
+
for (const windowId of [...( (this.profilesObject.emptyWindows.keys()))]) {
|
|
490
|
+
if (profile.id === this.profilesObject.emptyWindows.get(windowId)?.id) {
|
|
491
|
+
this.profilesObject.emptyWindows.delete(windowId);
|
|
492
|
+
}
|
|
433
493
|
}
|
|
434
494
|
for (const workspace of [...( (this.profilesObject.workspaces.keys()))]) {
|
|
435
495
|
if (profile.id === this.profilesObject.workspaces.get(workspace)?.id) {
|
|
@@ -450,9 +510,81 @@ let UserDataProfilesService = class UserDataProfilesService extends Disposable {
|
|
|
450
510
|
this.logService.error(error);
|
|
451
511
|
}
|
|
452
512
|
}
|
|
513
|
+
async setProfileForWorkspace(workspaceIdentifier, profileToSet) {
|
|
514
|
+
if (!this.enabled) {
|
|
515
|
+
throw new Error(`Profiles are disabled in the current environment.`);
|
|
516
|
+
}
|
|
517
|
+
const profile = this.profiles.find(p => p.id === profileToSet.id);
|
|
518
|
+
if (!profile) {
|
|
519
|
+
throw new Error(`Profile '${profileToSet.name}' does not exist`);
|
|
520
|
+
}
|
|
521
|
+
this.updateWorkspaceAssociation(workspaceIdentifier, profile);
|
|
522
|
+
}
|
|
523
|
+
unsetWorkspace(workspaceIdentifier, transient) {
|
|
524
|
+
if (!this.enabled) {
|
|
525
|
+
throw new Error(`Profiles are disabled in the current environment.`);
|
|
526
|
+
}
|
|
527
|
+
this.updateWorkspaceAssociation(workspaceIdentifier, undefined, transient);
|
|
528
|
+
}
|
|
529
|
+
async resetWorkspaces() {
|
|
530
|
+
this.transientProfilesObject.workspaces.clear();
|
|
531
|
+
this.transientProfilesObject.emptyWindows.clear();
|
|
532
|
+
this.profilesObject.workspaces.clear();
|
|
533
|
+
this.profilesObject.emptyWindows.clear();
|
|
534
|
+
this.updateStoredProfileAssociations();
|
|
535
|
+
this._onDidResetWorkspaces.fire();
|
|
536
|
+
}
|
|
537
|
+
async cleanUp() {
|
|
538
|
+
if (!this.enabled) {
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
if (await this.fileService.exists(this.profilesHome)) {
|
|
542
|
+
const stat = await this.fileService.resolve(this.profilesHome);
|
|
543
|
+
await Promise.all((stat.children || [])
|
|
544
|
+
.filter(child => child.isDirectory && this.profiles.every(p => !this.uriIdentityService.extUri.isEqual(p.location, child.resource)))
|
|
545
|
+
.map(child => this.fileService.del(child.resource, { recursive: true })));
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
async cleanUpTransientProfiles() {
|
|
549
|
+
if (!this.enabled) {
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
const unAssociatedTransientProfiles = this.transientProfilesObject.profiles.filter(p => !this.isProfileAssociatedToWorkspace(p));
|
|
553
|
+
await Promise.allSettled(unAssociatedTransientProfiles.map(p => this.removeProfile(p)));
|
|
554
|
+
}
|
|
555
|
+
getProfileForWorkspace(workspaceIdentifier) {
|
|
556
|
+
const workspace = this.getWorkspace(workspaceIdentifier);
|
|
557
|
+
return URI.isUri(workspace) ? this.transientProfilesObject.workspaces.get(workspace) ?? this.profilesObject.workspaces.get(workspace) : this.transientProfilesObject.emptyWindows.get(workspace) ?? this.profilesObject.emptyWindows.get(workspace);
|
|
558
|
+
}
|
|
559
|
+
getWorkspace(workspaceIdentifier) {
|
|
560
|
+
if (isSingleFolderWorkspaceIdentifier(workspaceIdentifier)) {
|
|
561
|
+
return workspaceIdentifier.uri;
|
|
562
|
+
}
|
|
563
|
+
if (isWorkspaceIdentifier(workspaceIdentifier)) {
|
|
564
|
+
return workspaceIdentifier.configPath;
|
|
565
|
+
}
|
|
566
|
+
return workspaceIdentifier.id;
|
|
567
|
+
}
|
|
568
|
+
isProfileAssociatedToWorkspace(profile) {
|
|
569
|
+
if ([...( (this.transientProfilesObject.emptyWindows.values()))].some(windowProfile => this.uriIdentityService.extUri.isEqual(windowProfile.location, profile.location))) {
|
|
570
|
+
return true;
|
|
571
|
+
}
|
|
572
|
+
if ([...( (this.transientProfilesObject.workspaces.values()))].some(workspaceProfile => this.uriIdentityService.extUri.isEqual(workspaceProfile.location, profile.location))) {
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
if ([...( (this.profilesObject.emptyWindows.values()))].some(windowProfile => this.uriIdentityService.extUri.isEqual(windowProfile.location, profile.location))) {
|
|
576
|
+
return true;
|
|
577
|
+
}
|
|
578
|
+
if ([...( (this.profilesObject.workspaces.values()))].some(workspaceProfile => this.uriIdentityService.extUri.isEqual(workspaceProfile.location, profile.location))) {
|
|
579
|
+
return true;
|
|
580
|
+
}
|
|
581
|
+
return false;
|
|
582
|
+
}
|
|
453
583
|
updateProfiles(added, removed, updated) {
|
|
584
|
+
const allProfiles = [...this.profiles, ...added];
|
|
454
585
|
const storedProfiles = [];
|
|
455
|
-
|
|
586
|
+
this.transientProfilesObject.profiles = [];
|
|
587
|
+
for (let profile of allProfiles) {
|
|
456
588
|
if (profile.isDefault) {
|
|
457
589
|
continue;
|
|
458
590
|
}
|
|
@@ -460,7 +592,12 @@ let UserDataProfilesService = class UserDataProfilesService extends Disposable {
|
|
|
460
592
|
continue;
|
|
461
593
|
}
|
|
462
594
|
profile = updated.find(p => profile.id === p.id) ?? profile;
|
|
463
|
-
|
|
595
|
+
if (profile.isTransient) {
|
|
596
|
+
this.transientProfilesObject.profiles.push(profile);
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
storedProfiles.push({ location: profile.location, name: profile.name, shortName: profile.shortName, useDefaultFlags: profile.useDefaultFlags });
|
|
600
|
+
}
|
|
464
601
|
}
|
|
465
602
|
this.saveStoredProfiles(storedProfiles);
|
|
466
603
|
this._profilesObject = undefined;
|
|
@@ -469,32 +606,64 @@ let UserDataProfilesService = class UserDataProfilesService extends Disposable {
|
|
|
469
606
|
triggerProfilesChanges(added, removed, updated) {
|
|
470
607
|
this._onDidChangeProfiles.fire({ added, removed, updated, all: this.profiles });
|
|
471
608
|
}
|
|
472
|
-
updateWorkspaceAssociation(workspaceIdentifier, newProfile) {
|
|
609
|
+
updateWorkspaceAssociation(workspaceIdentifier, newProfile, transient) {
|
|
610
|
+
transient = newProfile?.isTransient ? true : transient;
|
|
611
|
+
if (!transient) {
|
|
612
|
+
this.updateWorkspaceAssociation(workspaceIdentifier, undefined, true);
|
|
613
|
+
}
|
|
473
614
|
const workspace = this.getWorkspace(workspaceIdentifier);
|
|
615
|
+
const profilesObject = transient ? this.transientProfilesObject : this.profilesObject;
|
|
474
616
|
if (URI.isUri(workspace)) {
|
|
475
|
-
|
|
476
|
-
if (newProfile
|
|
477
|
-
|
|
617
|
+
profilesObject.workspaces.delete(workspace);
|
|
618
|
+
if (newProfile) {
|
|
619
|
+
profilesObject.workspaces.set(workspace, newProfile);
|
|
478
620
|
}
|
|
479
621
|
}
|
|
480
622
|
else {
|
|
481
|
-
|
|
623
|
+
profilesObject.emptyWindows.delete(workspace);
|
|
624
|
+
if (newProfile) {
|
|
625
|
+
profilesObject.emptyWindows.set(workspace, newProfile);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
if (!transient) {
|
|
629
|
+
this.updateStoredProfileAssociations();
|
|
482
630
|
}
|
|
483
|
-
this.updateStoredProfileAssociations();
|
|
484
631
|
}
|
|
485
632
|
updateStoredProfileAssociations() {
|
|
486
633
|
const workspaces = {};
|
|
487
634
|
for (const [workspace, profile] of this.profilesObject.workspaces.entries()) {
|
|
488
|
-
workspaces[( (workspace.toString()))] =
|
|
635
|
+
workspaces[( (workspace.toString()))] = profile.id;
|
|
636
|
+
}
|
|
637
|
+
const emptyWindows = {};
|
|
638
|
+
for (const [windowId, profile] of this.profilesObject.emptyWindows.entries()) {
|
|
639
|
+
emptyWindows[( (windowId.toString()))] = profile.id;
|
|
489
640
|
}
|
|
490
|
-
|
|
491
|
-
this.saveStoredProfileAssociations({ workspaces, emptyWindow });
|
|
641
|
+
this.saveStoredProfileAssociations({ workspaces, emptyWindows });
|
|
492
642
|
this._profilesObject = undefined;
|
|
493
643
|
}
|
|
644
|
+
migrateStoredProfileAssociations(storedProfileAssociations) {
|
|
645
|
+
const workspaces = {};
|
|
646
|
+
const defaultProfile = this.createDefaultProfile();
|
|
647
|
+
if (storedProfileAssociations.workspaces) {
|
|
648
|
+
for (const [workspace, location] of Object.entries(storedProfileAssociations.workspaces)) {
|
|
649
|
+
const uri = ( (URI.parse(location)));
|
|
650
|
+
workspaces[workspace] = this.uriIdentityService.extUri.isEqual(uri, defaultProfile.location) ? defaultProfile.id : this.uriIdentityService.extUri.basename(uri);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
const emptyWindows = {};
|
|
654
|
+
if (storedProfileAssociations.emptyWindows) {
|
|
655
|
+
for (const [workspace, location] of Object.entries(storedProfileAssociations.emptyWindows)) {
|
|
656
|
+
const uri = ( (URI.parse(location)));
|
|
657
|
+
emptyWindows[workspace] = this.uriIdentityService.extUri.isEqual(uri, defaultProfile.location) ? defaultProfile.id : this.uriIdentityService.extUri.basename(uri);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
return { workspaces, emptyWindows };
|
|
661
|
+
}
|
|
494
662
|
getStoredProfiles() { return []; }
|
|
495
663
|
saveStoredProfiles(storedProfiles) { throw new Error('not implemented'); }
|
|
496
664
|
getStoredProfileAssociations() { return {}; }
|
|
497
665
|
saveStoredProfileAssociations(storedProfileAssociations) { throw new Error('not implemented'); }
|
|
666
|
+
getDefaultProfileExtensionsLocation() { return undefined; }
|
|
498
667
|
};
|
|
499
668
|
UserDataProfilesService.PROFILES_KEY = 'userDataProfiles';
|
|
500
669
|
UserDataProfilesService.PROFILE_ASSOCIATIONS_KEY = 'profileAssociations';
|
|
@@ -522,6 +691,17 @@ var StorageTarget;
|
|
|
522
691
|
StorageTarget[StorageTarget["USER"] = 0] = "USER";
|
|
523
692
|
StorageTarget[StorageTarget["MACHINE"] = 1] = "MACHINE";
|
|
524
693
|
})(StorageTarget || (StorageTarget = {}))));
|
|
694
|
+
function loadKeyTargets(storage) {
|
|
695
|
+
const keysRaw = storage.get(TARGET_KEY);
|
|
696
|
+
if (keysRaw) {
|
|
697
|
+
try {
|
|
698
|
+
return JSON.parse(keysRaw);
|
|
699
|
+
}
|
|
700
|
+
catch (error) {
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
return Object.create(null);
|
|
704
|
+
}
|
|
525
705
|
class AbstractStorageService extends Disposable {
|
|
526
706
|
constructor(options = { flushInterval: AbstractStorageService.DEFAULT_FLUSH_INTERVAL }) {
|
|
527
707
|
super();
|
|
@@ -678,15 +858,8 @@ class AbstractStorageService extends Disposable {
|
|
|
678
858
|
}
|
|
679
859
|
}
|
|
680
860
|
loadKeyTargets(scope) {
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
try {
|
|
684
|
-
return JSON.parse(keysRaw);
|
|
685
|
-
}
|
|
686
|
-
catch (error) {
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
return Object.create(null);
|
|
861
|
+
const storage = this.getStorage(scope);
|
|
862
|
+
return storage ? loadKeyTargets(storage) : Object.create(null);
|
|
690
863
|
}
|
|
691
864
|
isNew(scope) {
|
|
692
865
|
return this.getBoolean(IS_NEW_KEY, scope) === true;
|
|
@@ -828,6 +1001,13 @@ function isEditorGroup(obj) {
|
|
|
828
1001
|
const group = obj;
|
|
829
1002
|
return !!group && typeof group.id === 'number' && Array.isArray(group.editors);
|
|
830
1003
|
}
|
|
1004
|
+
function preferredSideBySideGroupDirection(configurationService) {
|
|
1005
|
+
const openSideBySideDirection = configurationService.getValue('workbench.editor.openSideBySideDirection');
|
|
1006
|
+
if (openSideBySideDirection === 'down') {
|
|
1007
|
+
return 1 ;
|
|
1008
|
+
}
|
|
1009
|
+
return 3 ;
|
|
1010
|
+
}
|
|
831
1011
|
const IEditorService = ( (createDecorator('editorService')));
|
|
832
1012
|
const ACTIVE_GROUP = -1;
|
|
833
1013
|
const SIDE_GROUP = -2;
|
|
@@ -866,4 +1046,4 @@ var Services;
|
|
|
866
1046
|
}
|
|
867
1047
|
Services.install = install;
|
|
868
1048
|
})(Services || (Services = {})));
|
|
869
|
-
export { ACTIVE_GROUP as A,
|
|
1049
|
+
export { ACTIVE_GROUP as A, FileSystemProviderErrorCode as B, ensureFileSystemProviderError as C, etag as D, FileOperationEvent as E, FileType as F, toFileOperationResult as G, ETAG_DISABLED as H, IEditorGroupsService as I, hasFileAtomicReadCapability as J, hasFileFolderCopyCapability as K, hasFileCloneCapability as L, FileSystemProviderError as M, NotModifiedSinceFileOperationError as N, FILES_ASSOCIATIONS_CONFIG as O, markAsFileSystemProviderError as P, preferredSideBySideGroupDirection as Q, productSchemaId as R, Services as S, TooLargeFileOperationError as T, FilePermission as a, IEditorService as b, IFileService as c, IHostService as d, ILanguageStatusService as e, IPaneCompositePartService as f, IPathService as g, IProductService as h, ISnippetsService as i, ITextFileService as j, IUriIdentityService as k, IWorkbenchEnvironmentService as l, IWorkingCopyFileService as m, StorageScope as n, StorageTarget as o, SIDE_GROUP as p, isPreferredGroup as q, IUserDataProfilesService as r, refineServiceDecorator as s, createFileSystemProviderError as t, FileChangesEvent as u, FileOperationError as v, hasOpenReadWriteCloseCapability as w, hasReadWriteCapability as x, hasFileReadStreamCapability as y, toFileSystemProviderErrorCode as z };
|