Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename StorageScope.Global to Profile #152703

Merged
merged 1 commit into from Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/vs/code/electron-main/app.ts
Expand Up @@ -70,7 +70,7 @@ import { SharedProcess } from 'vs/platform/sharedProcess/electron-main/sharedPro
import { ISignService } from 'vs/platform/sign/common/sign';
import { IStateMainService } from 'vs/platform/state/electron-main/state';
import { StorageDatabaseChannel } from 'vs/platform/storage/electron-main/storageIpc';
import { ApplicationStorageMainService, IApplicationStorageMainService, IStorageMainService, StorageMainService } from 'vs/platform/storage/electron-main/storageMainService';
import { GlobalStorageMainService, IGlobalStorageMainService, IStorageMainService, StorageMainService } from 'vs/platform/storage/electron-main/storageMainService';
import { resolveCommonProperties } from 'vs/platform/telemetry/common/commonProperties';
import { ITelemetryService, machineIdKey, TelemetryLevel } from 'vs/platform/telemetry/common/telemetry';
import { TelemetryAppenderClient } from 'vs/platform/telemetry/common/telemetryIpc';
Expand Down Expand Up @@ -648,7 +648,7 @@ export class CodeApplication extends Disposable {

// Storage
services.set(IStorageMainService, new SyncDescriptor(StorageMainService));
services.set(IApplicationStorageMainService, new SyncDescriptor(ApplicationStorageMainService));
services.set(IGlobalStorageMainService, new SyncDescriptor(GlobalStorageMainService));

// External terminal
if (isWindows) {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/editor/contrib/find/browser/findWidget.ts
Expand Up @@ -176,7 +176,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
this._storageService = storageService;
this._notificationService = notificationService;

this._ctrlEnterReplaceAllWarningPrompted = !!storageService.getBoolean(ctrlEnterReplaceAllWarningPromptedKey, StorageScope.GLOBAL);
this._ctrlEnterReplaceAllWarningPrompted = !!storageService.getBoolean(ctrlEnterReplaceAllWarningPromptedKey, StorageScope.PROFILE);

this._isVisible = false;
this._isReplaceVisible = false;
Expand Down Expand Up @@ -902,7 +902,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
);

this._ctrlEnterReplaceAllWarningPrompted = true;
this._storageService.store(ctrlEnterReplaceAllWarningPromptedKey, true, StorageScope.GLOBAL, StorageTarget.USER);
this._storageService.store(ctrlEnterReplaceAllWarningPromptedKey, true, StorageScope.PROFILE, StorageTarget.USER);
}

this._replaceInput.inputBox.insertAtCursor('\n');
Expand Down
Expand Up @@ -94,15 +94,15 @@ export abstract class ReferencesController implements IEditorContribution {
}
}));
const storageKey = 'peekViewLayout';
const data = LayoutData.fromJSON(this._storageService.get(storageKey, StorageScope.GLOBAL, '{}'));
const data = LayoutData.fromJSON(this._storageService.get(storageKey, StorageScope.PROFILE, '{}'));
this._widget = this._instantiationService.createInstance(ReferenceWidget, this._editor, this._defaultTreeKeyboardSupport, data);
this._widget.setTitle(nls.localize('labelLoading', "Loading..."));
this._widget.show(range);

this._disposables.add(this._widget.onDidClose(() => {
modelPromise.cancel();
if (this._widget) {
this._storageService.store(storageKey, JSON.stringify(this._widget.layoutData), StorageScope.GLOBAL, StorageTarget.MACHINE);
this._storageService.store(storageKey, JSON.stringify(this._widget.layoutData), StorageScope.PROFILE, StorageTarget.MACHINE);
this._widget = undefined;
}
this.closeWidget();
Expand Down
4 changes: 2 additions & 2 deletions src/vs/editor/contrib/suggest/browser/suggestMemory.ts
Expand Up @@ -274,7 +274,7 @@ export class SuggestMemoryService implements ISuggestMemoryService {

try {
const share = this._configService.getValue<boolean>('editor.suggest.shareSuggestSelections');
const scope = share ? StorageScope.GLOBAL : StorageScope.WORKSPACE;
const scope = share ? StorageScope.PROFILE : StorageScope.WORKSPACE;
const raw = this._storageService.get(`${SuggestMemoryService._storagePrefix}/${mode}`, scope);
if (raw) {
this._strategy.fromJSON(JSON.parse(raw));
Expand All @@ -290,7 +290,7 @@ export class SuggestMemoryService implements ISuggestMemoryService {
private _saveState() {
if (this._strategy) {
const share = this._configService.getValue<boolean>('editor.suggest.shareSuggestSelections');
const scope = share ? StorageScope.GLOBAL : StorageScope.WORKSPACE;
const scope = share ? StorageScope.PROFILE : StorageScope.WORKSPACE;
const raw = JSON.stringify(this._strategy);
this._storageService.store(`${SuggestMemoryService._storagePrefix}/${this._strategy.name}`, raw, scope, StorageTarget.MACHINE);
}
Expand Down
10 changes: 5 additions & 5 deletions src/vs/editor/contrib/suggest/browser/suggestWidget.ts
Expand Up @@ -75,7 +75,7 @@ class PersistedWidgetSize {
}

restore(): dom.Dimension | undefined {
const raw = this._service.get(this._key, StorageScope.GLOBAL) ?? '';
const raw = this._service.get(this._key, StorageScope.PROFILE) ?? '';
try {
const obj = JSON.parse(raw);
if (dom.Dimension.is(obj)) {
Expand All @@ -88,11 +88,11 @@ class PersistedWidgetSize {
}

store(size: dom.Dimension) {
this._service.store(this._key, JSON.stringify(size), StorageScope.GLOBAL, StorageTarget.MACHINE);
this._service.store(this._key, JSON.stringify(size), StorageScope.PROFILE, StorageTarget.MACHINE);
}

reset(): void {
this._service.remove(this._key, StorageScope.GLOBAL);
this._service.remove(this._key, StorageScope.PROFILE);
}
}

Expand Down Expand Up @@ -865,11 +865,11 @@ export class SuggestWidget implements IDisposable {
}

private _isDetailsVisible(): boolean {
return this._storageService.getBoolean('expandSuggestionDocs', StorageScope.GLOBAL, false);
return this._storageService.getBoolean('expandSuggestionDocs', StorageScope.PROFILE, false);
}

private _setDetailsVisible(value: boolean) {
this._storageService.store('expandSuggestionDocs', value, StorageScope.GLOBAL, StorageTarget.USER);
this._storageService.store('expandSuggestionDocs', value, StorageScope.PROFILE, StorageTarget.USER);
}

forceRenderingAbove() {
Expand Down
Expand Up @@ -84,11 +84,11 @@ export class GlobalExtensionEnablementService extends Disposable implements IGlo
}

private _getExtensions(storageId: string): IExtensionIdentifier[] {
return this.storageManger.get(storageId, StorageScope.GLOBAL);
return this.storageManger.get(storageId, StorageScope.PROFILE);
}

private _setExtensions(storageId: string, extensions: IExtensionIdentifier[]): void {
this.storageManger.set(storageId, extensions, StorageScope.GLOBAL);
this.storageManger.set(storageId, extensions, StorageScope.PROFILE);
}

}
Expand All @@ -107,7 +107,7 @@ export class StorageManager extends Disposable {

get(key: string, scope: StorageScope): IExtensionIdentifier[] {
let value: string;
if (scope === StorageScope.GLOBAL) {
if (scope === StorageScope.PROFILE) {
if (isUndefinedOrNull(this.storage[key])) {
this.storage[key] = this._get(key, scope);
}
Expand All @@ -122,7 +122,7 @@ export class StorageManager extends Disposable {
const newValue: string = JSON.stringify(value.map(({ id, uuid }) => (<IExtensionIdentifier>{ id, uuid })));
const oldValue = this._get(key, scope);
if (oldValue !== newValue) {
if (scope === StorageScope.GLOBAL) {
if (scope === StorageScope.PROFILE) {
if (value.length) {
this.storage[key] = newValue;
} else {
Expand All @@ -134,7 +134,7 @@ export class StorageManager extends Disposable {
}

private onDidStorageChange(storageChangeEvent: IStorageValueChangeEvent): void {
if (storageChangeEvent.scope === StorageScope.GLOBAL) {
if (storageChangeEvent.scope === StorageScope.PROFILE) {
if (!isUndefinedOrNull(this.storage[storageChangeEvent.key])) {
const newValue = this._get(storageChangeEvent.key, storageChangeEvent.scope);
if (newValue !== this.storage[storageChangeEvent.key]) {
Expand Down
24 changes: 12 additions & 12 deletions src/vs/platform/extensionManagement/common/extensionStorage.ts
Expand Up @@ -68,13 +68,13 @@ export class ExtensionStorageService extends Disposable implements IExtensionSto
}
}
for (const key of extensionVersionsToRemove) {
storageService.remove(key, StorageScope.GLOBAL);
storageService.remove(key, StorageScope.PROFILE);
}
}

private static readAllExtensionsWithKeysForSync(storageService: IStorageService): Map<string, string[]> {
const extensionsWithKeysForSync = new Map<string, string[]>();
const keys = storageService.keys(StorageScope.GLOBAL, StorageTarget.MACHINE);
const keys = storageService.keys(StorageScope.PROFILE, StorageTarget.MACHINE);
for (const key of keys) {
const extensionIdWithVersion = ExtensionStorageService.fromKey(key);
if (extensionIdWithVersion) {
Expand Down Expand Up @@ -104,7 +104,7 @@ export class ExtensionStorageService extends Disposable implements IExtensionSto
}

private onDidChangeStorageValue(e: IStorageValueChangeEvent): void {
if (e.scope !== StorageScope.GLOBAL) {
if (e.scope !== StorageScope.PROFILE) {
return;
}

Expand All @@ -117,7 +117,7 @@ export class ExtensionStorageService extends Disposable implements IExtensionSto
// Keys for sync of an extension has changed
const extensionIdWithVersion = ExtensionStorageService.fromKey(e.key);
if (extensionIdWithVersion) {
if (this.storageService.get(e.key, StorageScope.GLOBAL) === undefined) {
if (this.storageService.get(e.key, StorageScope.PROFILE) === undefined) {
this.extensionsWithKeysForSync.delete(extensionIdWithVersion.id.toLowerCase());
} else {
let versions = this.extensionsWithKeysForSync.get(extensionIdWithVersion.id.toLowerCase());
Expand All @@ -142,7 +142,7 @@ export class ExtensionStorageService extends Disposable implements IExtensionSto

getExtensionState(extension: IExtension | IGalleryExtension | string, global: boolean): IStringDictionary<any> | undefined {
const extensionId = this.getExtensionId(extension);
const jsonValue = this.storageService.get(extensionId, global ? StorageScope.GLOBAL : StorageScope.WORKSPACE);
const jsonValue = this.storageService.get(extensionId, global ? StorageScope.PROFILE : StorageScope.WORKSPACE);
if (jsonValue) {
try {
return JSON.parse(jsonValue);
Expand All @@ -159,19 +159,19 @@ export class ExtensionStorageService extends Disposable implements IExtensionSto
setExtensionState(extension: IExtension | IGalleryExtension | string, state: IStringDictionary<any> | undefined, global: boolean): void {
const extensionId = this.getExtensionId(extension);
if (state === undefined) {
this.storageService.remove(extensionId, global ? StorageScope.GLOBAL : StorageScope.WORKSPACE);
this.storageService.remove(extensionId, global ? StorageScope.PROFILE : StorageScope.WORKSPACE);
} else {
this.storageService.store(extensionId, JSON.stringify(state), global ? StorageScope.GLOBAL : StorageScope.WORKSPACE, StorageTarget.MACHINE /* Extension state is synced separately through extensions */);
this.storageService.store(extensionId, JSON.stringify(state), global ? StorageScope.PROFILE : StorageScope.WORKSPACE, StorageTarget.MACHINE /* Extension state is synced separately through extensions */);
}
}

setKeysForSync(extensionIdWithVersion: IExtensionIdWithVersion, keys: string[]): void {
this.storageService.store(ExtensionStorageService.toKey(extensionIdWithVersion), JSON.stringify(keys), StorageScope.GLOBAL, StorageTarget.MACHINE);
this.storageService.store(ExtensionStorageService.toKey(extensionIdWithVersion), JSON.stringify(keys), StorageScope.PROFILE, StorageTarget.MACHINE);
}

getKeysForSync(extensionIdWithVersion: IExtensionIdWithVersion): string[] | undefined {
const extensionKeysForSyncFromProduct = this.productService.extensionSyncedKeys?.[extensionIdWithVersion.id.toLowerCase()];
const extensionKeysForSyncFromStorageValue = this.storageService.get(ExtensionStorageService.toKey(extensionIdWithVersion), StorageScope.GLOBAL);
const extensionKeysForSyncFromStorageValue = this.storageService.get(ExtensionStorageService.toKey(extensionIdWithVersion), StorageScope.PROFILE);
const extensionKeysForSyncFromStorage = extensionKeysForSyncFromStorageValue ? JSON.parse(extensionKeysForSyncFromStorageValue) : undefined;

return extensionKeysForSyncFromStorage && extensionKeysForSyncFromProduct
Expand All @@ -194,7 +194,7 @@ export class ExtensionStorageService extends Disposable implements IExtensionSto
}

private get migrationList(): [string, string][] {
const value = this.storageService.get('extensionStorage.migrationList', StorageScope.APPLICATION, '[]');
const value = this.storageService.get('extensionStorage.migrationList', StorageScope.GLOBAL, '[]');
try {
const migrationList = JSON.parse(value);
if (isArray(migrationList)) {
Expand All @@ -206,9 +206,9 @@ export class ExtensionStorageService extends Disposable implements IExtensionSto

private set migrationList(migrationList: [string, string][]) {
if (migrationList.length) {
this.storageService.store('extensionStorage.migrationList', JSON.stringify(migrationList), StorageScope.APPLICATION, StorageTarget.MACHINE);
this.storageService.store('extensionStorage.migrationList', JSON.stringify(migrationList), StorageScope.GLOBAL, StorageTarget.MACHINE);
} else {
this.storageService.remove('extensionStorage.migrationList', StorageScope.APPLICATION);
this.storageService.remove('extensionStorage.migrationList', StorageScope.GLOBAL);
}
}

Expand Down
Expand Up @@ -256,7 +256,7 @@ export class ExtensionTipsService extends BaseExtensionTipsService {
}

private getLastPromptedMediumExeTime(): number {
let value = this.storageService.getNumber(lastPromptedMediumImpExeTimeStorageKey, StorageScope.APPLICATION);
let value = this.storageService.getNumber(lastPromptedMediumImpExeTimeStorageKey, StorageScope.GLOBAL);
if (!value) {
value = Date.now();
this.updateLastPromptedMediumExeTime(value);
Expand All @@ -265,17 +265,17 @@ export class ExtensionTipsService extends BaseExtensionTipsService {
}

private updateLastPromptedMediumExeTime(value: number): void {
this.storageService.store(lastPromptedMediumImpExeTimeStorageKey, value, StorageScope.APPLICATION, StorageTarget.MACHINE);
this.storageService.store(lastPromptedMediumImpExeTimeStorageKey, value, StorageScope.GLOBAL, StorageTarget.MACHINE);
}

private getPromptedExecutableTips(): IStringDictionary<string[]> {
return JSON.parse(this.storageService.get(promptedExecutableTipsStorageKey, StorageScope.APPLICATION, '{}'));
return JSON.parse(this.storageService.get(promptedExecutableTipsStorageKey, StorageScope.GLOBAL, '{}'));
}

private addToRecommendedExecutables(exeName: string, tips: IExecutableBasedExtensionTip[]) {
const promptedExecutableTips = this.getPromptedExecutableTips();
promptedExecutableTips[exeName] = tips.map(({ extensionId }) => extensionId.toLowerCase());
this.storageService.store(promptedExecutableTipsStorageKey, JSON.stringify(promptedExecutableTips), StorageScope.APPLICATION, StorageTarget.USER);
this.storageService.store(promptedExecutableTipsStorageKey, JSON.stringify(promptedExecutableTips), StorageScope.GLOBAL, StorageTarget.USER);
}

private groupByInstalled(recommendationsToSuggest: string[], local: ILocalExtension[]): { installed: string[]; uninstalled: string[] } {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/externalServices/common/serviceMachineId.ts
Expand Up @@ -10,7 +10,7 @@ import { IFileService } from 'vs/platform/files/common/files';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';

export async function getServiceMachineId(environmentService: IEnvironmentService, fileService: IFileService, storageService: IStorageService | undefined): Promise<string> {
let uuid: string | null = storageService ? storageService.get('storage.serviceMachineId', StorageScope.APPLICATION) || null : null;
let uuid: string | null = storageService ? storageService.get('storage.serviceMachineId', StorageScope.GLOBAL) || null : null;
if (uuid) {
return uuid;
}
Expand All @@ -31,7 +31,7 @@ export async function getServiceMachineId(environmentService: IEnvironmentServic
}
}

storageService?.store('storage.serviceMachineId', uuid, StorageScope.APPLICATION, StorageTarget.MACHINE);
storageService?.store('storage.serviceMachineId', uuid, StorageScope.GLOBAL, StorageTarget.MACHINE);

return uuid;
}
6 changes: 3 additions & 3 deletions src/vs/platform/notification/common/notification.ts
Expand Up @@ -48,13 +48,13 @@ export enum NeverShowAgainScope {
* Will never show this notification on any workspace of the same
* profile again.
*/
GLOBAL,
PROFILE,

/**
* Will never show this notification on any workspace across all
* profiles again.
*/
APPLICATION
GLOBAL
}

export interface INeverShowAgainOptions {
Expand All @@ -73,7 +73,7 @@ export interface INeverShowAgainOptions {
/**
* Whether to persist the choice in the current workspace or for all workspaces. By
* default it will be persisted for all workspaces across all profiles
* (= `NeverShowAgainScope.APPLICATION`).
* (= `NeverShowAgainScope.GLOBAL`).
*/
readonly scope?: NeverShowAgainScope;
}
Expand Down
8 changes: 4 additions & 4 deletions src/vs/platform/quickinput/browser/commandsQuickAccess.ts
Expand Up @@ -232,7 +232,7 @@ export class CommandsHistory extends Disposable {
}

private load(): void {
const raw = this.storageService.get(CommandsHistory.PREF_KEY_CACHE, StorageScope.GLOBAL);
const raw = this.storageService.get(CommandsHistory.PREF_KEY_CACHE, StorageScope.PROFILE);
let serializedCache: ISerializedCommandHistory | undefined;
if (raw) {
try {
Expand All @@ -253,7 +253,7 @@ export class CommandsHistory extends Disposable {
entries.forEach(entry => cache.set(entry.key, entry.value));
}

CommandsHistory.counter = this.storageService.getNumber(CommandsHistory.PREF_KEY_COUNTER, StorageScope.GLOBAL, CommandsHistory.counter);
CommandsHistory.counter = this.storageService.getNumber(CommandsHistory.PREF_KEY_COUNTER, StorageScope.PROFILE, CommandsHistory.counter);
}

push(commandId: string): void {
Expand All @@ -278,8 +278,8 @@ export class CommandsHistory extends Disposable {
const serializedCache: ISerializedCommandHistory = { usesLRU: true, entries: [] };
CommandsHistory.cache.forEach((value, key) => serializedCache.entries.push({ key, value }));

storageService.store(CommandsHistory.PREF_KEY_CACHE, JSON.stringify(serializedCache), StorageScope.GLOBAL, StorageTarget.USER);
storageService.store(CommandsHistory.PREF_KEY_COUNTER, CommandsHistory.counter, StorageScope.GLOBAL, StorageTarget.USER);
storageService.store(CommandsHistory.PREF_KEY_CACHE, JSON.stringify(serializedCache), StorageScope.PROFILE, StorageTarget.USER);
storageService.store(CommandsHistory.PREF_KEY_COUNTER, CommandsHistory.counter, StorageScope.PROFILE, StorageTarget.USER);
}

static getConfiguredCommandHistoryLength(configurationService: IConfigurationService): number {
Expand Down