Skip to content

Commit

Permalink
#176813 revert the feature
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jul 13, 2023
1 parent 2f1013a commit 0e623c1
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 218 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/c
import { isEqual } from 'vs/base/common/resources';
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
import { IStringDictionary } from 'vs/base/common/collections';
import { APPLY_ALL_PROFILES_SETTING, IWorkbenchConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { IWorkbenchConfigurationService } from 'vs/workbench/services/configuration/common/configuration';

export interface IPreferencesRenderer extends IDisposable {
render(): void;
Expand Down Expand Up @@ -616,14 +616,6 @@ class UnsupportedSettingsRenderer extends Disposable implements languages.CodeAc
if (configuration.scope === ConfigurationScope.APPLICATION) {
// If we're in a profile setting file, and the setting is application-scoped, fade it out.
markerData.push(this.generateUnsupportedApplicationSettingMarker(setting));
} else if (this.configurationService.isSettingAppliedForAllProfiles(setting.key)) {
// If we're in the non-default profile setting file, and the setting can be applied in all profiles, fade it out.
markerData.push({
severity: MarkerSeverity.Hint,
tags: [MarkerTag.Unnecessary],
...setting.range,
message: nls.localize('allProfileSettingWhileInNonDefaultProfileSetting', "This setting cannot be applied because it is configured to be applied in all profiles using setting {0}. Value from the default profile will be used instead.", APPLY_ALL_PROFILES_SETTING)
});
}
}
}
Expand Down
49 changes: 1 addition & 48 deletions src/vs/workbench/contrib/preferences/browser/settingsTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { IObjectTreeOptions } from 'vs/base/browser/ui/tree/objectTree';
import { ObjectTreeModel } from 'vs/base/browser/ui/tree/objectTreeModel';
import { ITreeFilter, ITreeModel, ITreeNode, ITreeRenderer, TreeFilterResult, TreeVisibility } from 'vs/base/browser/ui/tree/tree';
import { Action, IAction, Separator } from 'vs/base/common/actions';
import { distinct } from 'vs/base/common/arrays';
import { Codicon } from 'vs/base/common/codicons';
import { onUnexpectedError } from 'vs/base/common/errors';
import { Emitter, Event } from 'vs/base/common/event';
Expand Down Expand Up @@ -64,7 +63,7 @@ import { ISettingsEditorViewState, SettingsTreeElement, SettingsTreeGroupChild,
import { ExcludeSettingWidget, IListDataItem, IObjectDataItem, IObjectEnumOption, IObjectKeySuggester, IObjectValueSuggester, ISettingListChangeEvent, IncludeSettingWidget, ListSettingWidget, ObjectSettingCheckboxWidget, ObjectSettingDropdownWidget, ObjectValue } from 'vs/workbench/contrib/preferences/browser/settingsWidgets';
import { LANGUAGE_SETTING_TAG, SETTINGS_EDITOR_COMMAND_SHOW_CONTEXT_MENU } from 'vs/workbench/contrib/preferences/common/preferences';
import { settingsNumberInputBackground, settingsNumberInputBorder, settingsNumberInputForeground, settingsSelectBackground, settingsSelectBorder, settingsSelectForeground, settingsSelectListBorder, settingsTextInputBackground, settingsTextInputBorder, settingsTextInputForeground } from 'vs/workbench/contrib/preferences/common/settingsEditorColorRegistry';
import { APPLY_ALL_PROFILES_SETTING, IWorkbenchConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { IWorkbenchConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { ISetting, ISettingsGroup, SettingValueType } from 'vs/workbench/services/preferences/common/preferences';
Expand Down Expand Up @@ -902,11 +901,6 @@ export abstract class AbstractSettingRenderer extends Disposable implements ITre
}

template.indicatorsLabel.updateScopeOverrides(element, this._onDidClickOverrideElement, this._onApplyFilter);
template.elementDisposables.add(this._configService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(APPLY_ALL_PROFILES_SETTING)) {
template.indicatorsLabel.updateScopeOverrides(element, this._onDidClickOverrideElement, this._onApplyFilter);
}
}));

const onChange = (value: any) => this._onDidChangeSetting.fire({
key: element.setting.key,
Expand Down Expand Up @@ -1965,7 +1959,6 @@ export class SettingTreeRenderers {
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@IContextMenuService private readonly _contextMenuService: IContextMenuService,
@IContextViewService private readonly _contextViewService: IContextViewService,
@IUserDataProfilesService private readonly _userDataProfilesService: IUserDataProfilesService,
@IUserDataSyncEnablementService private readonly _userDataSyncEnablementService: IUserDataSyncEnablementService,
) {
this.settingActions = [
Expand Down Expand Up @@ -2024,9 +2017,6 @@ export class SettingTreeRenderers {

private getActionsForSetting(setting: ISetting, settingTarget: SettingsTarget): IAction[] {
const actions: IAction[] = [];
if (this._userDataProfilesService.isEnabled() && setting.scope !== ConfigurationScope.APPLICATION && settingTarget === ConfigurationTarget.USER_LOCAL) {
actions.push(this._instantiationService.createInstance(ApplySettingToAllProfilesAction, setting));
}
if (this._userDataSyncEnablementService.isEnabled() && !setting.disallowSyncIgnore) {
actions.push(this._instantiationService.createInstance(SyncSettingAction, setting));
}
Expand Down Expand Up @@ -2496,40 +2486,3 @@ class SyncSettingAction extends Action {
}

}

class ApplySettingToAllProfilesAction extends Action {
static readonly ID = 'settings.applyToAllProfiles';
static readonly LABEL = localize('applyToAllProfiles', "Apply Setting to all Profiles");

constructor(
private readonly setting: ISetting,
@IWorkbenchConfigurationService private readonly configService: IWorkbenchConfigurationService,
) {
super(ApplySettingToAllProfilesAction.ID, ApplySettingToAllProfilesAction.LABEL);
this._register(Event.filter(configService.onDidChangeConfiguration, e => e.affectsConfiguration(APPLY_ALL_PROFILES_SETTING))(() => this.update()));
this.update();
}

update() {
const allProfilesSettings = this.configService.getValue<string[]>(APPLY_ALL_PROFILES_SETTING);
this.checked = allProfilesSettings.includes(this.setting.key);
}

override async run(): Promise<void> {
// first remove the current setting completely from ignored settings
const value = this.configService.getValue<string[]>(APPLY_ALL_PROFILES_SETTING) ?? [];

if (this.checked) {
value.splice(value.indexOf(this.setting.key), 1);
} else {
value.push(this.setting.key);
}

const newValue = distinct(value);
await this.configService.updateValue(APPLY_ALL_PROFILES_SETTING, newValue.length ? newValue : undefined, ConfigurationTarget.USER_LOCAL);
if (!this.checked) {
await this.configService.updateValue(this.setting.key, this.configService.inspect(this.setting.key).userLocal?.value, ConfigurationTarget.USER_LOCAL);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { RunOnceScheduler } from 'vs/base/common/async';
import { FileChangeType, FileChangesEvent, IFileService, whenProviderRegistered, FileOperationError, FileOperationResult, FileOperation, FileOperationEvent } from 'vs/platform/files/common/files';
import { ConfigurationModel, ConfigurationModelParser, ConfigurationParseOptions, UserSettings } from 'vs/platform/configuration/common/configurationModels';
import { WorkspaceConfigurationModelParser, StandaloneConfigurationModelParser } from 'vs/workbench/services/configuration/common/configurationModels';
import { TASKS_CONFIGURATION_KEY, FOLDER_SETTINGS_NAME, LAUNCH_CONFIGURATION_KEY, IConfigurationCache, ConfigurationKey, REMOTE_MACHINE_SCOPES, FOLDER_SCOPES, WORKSPACE_SCOPES, APPLY_ALL_PROFILES_SETTING } from 'vs/workbench/services/configuration/common/configuration';
import { TASKS_CONFIGURATION_KEY, FOLDER_SETTINGS_NAME, LAUNCH_CONFIGURATION_KEY, IConfigurationCache, ConfigurationKey, REMOTE_MACHINE_SCOPES, FOLDER_SCOPES, WORKSPACE_SCOPES } from 'vs/workbench/services/configuration/common/configuration';
import { IStoredWorkspaceFolder } from 'vs/platform/workspaces/common/workspaces';
import { WorkbenchState, IWorkspaceFolder, IWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
import { ConfigurationScope, Extensions, IConfigurationRegistry, OVERRIDE_PROPERTY_REGEX } from 'vs/platform/configuration/common/configurationRegistry';
Expand Down Expand Up @@ -140,14 +140,6 @@ export class ApplicationConfiguration extends UserSettings {
return this.loadConfiguration();
}

override async loadConfiguration(): Promise<ConfigurationModel> {
const model = await super.loadConfiguration();
const value = model.getValue<string[]>(APPLY_ALL_PROFILES_SETTING);
const allProfilesSettings = Array.isArray(value) ? value : [];
return this.parseOptions.include || allProfilesSettings.length
? this.reparse({ ...this.parseOptions, include: allProfilesSettings })
: model;
}
}

export class UserConfiguration extends Disposable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ConfigurationModel, ConfigurationChangeEvent, mergeChanges } from 'vs/p
import { IConfigurationChangeEvent, ConfigurationTarget, IConfigurationOverrides, isConfigurationOverrides, IConfigurationData, IConfigurationValue, IConfigurationChange, ConfigurationTargetToString, IConfigurationUpdateOverrides, isConfigurationUpdateOverrides, IConfigurationService, IConfigurationUpdateOptions } from 'vs/platform/configuration/common/configuration';
import { IPolicyConfiguration, NullPolicyConfiguration, PolicyConfiguration } from 'vs/platform/configuration/common/configurations';
import { Configuration } from 'vs/workbench/services/configuration/common/configurationModels';
import { FOLDER_CONFIG_FOLDER_NAME, defaultSettingsSchemaId, userSettingsSchemaId, workspaceSettingsSchemaId, folderSettingsSchemaId, IConfigurationCache, machineSettingsSchemaId, LOCAL_MACHINE_SCOPES, IWorkbenchConfigurationService, RestrictedSettings, PROFILE_SCOPES, LOCAL_MACHINE_PROFILE_SCOPES, profileSettingsSchemaId, APPLY_ALL_PROFILES_SETTING } from 'vs/workbench/services/configuration/common/configuration';
import { FOLDER_CONFIG_FOLDER_NAME, defaultSettingsSchemaId, userSettingsSchemaId, workspaceSettingsSchemaId, folderSettingsSchemaId, IConfigurationCache, machineSettingsSchemaId, LOCAL_MACHINE_SCOPES, IWorkbenchConfigurationService, RestrictedSettings, PROFILE_SCOPES, LOCAL_MACHINE_PROFILE_SCOPES, profileSettingsSchemaId } from 'vs/workbench/services/configuration/common/configuration';
import { Registry } from 'vs/platform/registry/common/platform';
import { IConfigurationRegistry, Extensions, allSettings, windowSettings, resourceSettings, applicationSettings, machineSettings, machineOverridableSettings, ConfigurationScope, IConfigurationPropertySchema, keyFromOverrideIdentifiers, OVERRIDE_PROPERTY_PATTERN, resourceLanguageSettingsSchemaId, configurationDefaultsSchemaId } from 'vs/platform/configuration/common/configurationRegistry';
import { IStoredWorkspaceFolder, isStoredWorkspaceFolder, IWorkspaceFolderCreationData, getStoredWorkspaceFolder, toWorkspaceFolders } from 'vs/platform/workspaces/common/workspaces';
Expand Down Expand Up @@ -44,7 +44,6 @@ import { IPolicyService, NullPolicyService } from 'vs/platform/policy/common/pol
import { IUserDataProfile, IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
import { IJSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditing';
import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
import { workbenchConfigurationNodeBase } from 'vs/workbench/common/configuration';

function getLocalUserConfigurationScopes(userDataProfile: IUserDataProfile, hasRemote: boolean): ConfigurationScope[] | undefined {
return userDataProfile.isDefault
Expand Down Expand Up @@ -490,11 +489,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
}

isSettingAppliedForAllProfiles(key: string): boolean {
if (this.configurationRegistry.getConfigurationProperties()[key]?.scope === ConfigurationScope.APPLICATION) {
return true;
}
const allProfilesSettings = this.getValue<string[]>(APPLY_ALL_PROFILES_SETTING) ?? [];
return Array.isArray(allProfilesSettings) && allProfilesSettings.includes(key);
return this.configurationRegistry.getConfigurationProperties()[key]?.scope === ConfigurationScope.APPLICATION;
}

private async createWorkspace(arg: IAnyWorkspaceIdentifier): Promise<Workspace> {
Expand Down Expand Up @@ -606,10 +601,6 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
const initUserConfiguration = async () => {
mark('code/willInitUserConfiguration');
const result = await Promise.all([this.localUserConfiguration.initialize(), this.remoteUserConfiguration ? this.remoteUserConfiguration.initialize() : Promise.resolve(new ConfigurationModel())]);
if (this.applicationConfiguration) {
const applicationConfigurationModel = await initApplicationConfigurationPromise;
result[0] = this.localUserConfiguration.reparse({ exclude: applicationConfigurationModel.getValue(APPLY_ALL_PROFILES_SETTING) });
}
mark('code/didInitUserConfiguration');
return result;
};
Expand Down Expand Up @@ -723,12 +714,8 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
promises.push(this.reloadApplicationConfiguration(true));
}
}
let [localUser, application] = await Promise.all(promises);
application = application ?? this._configuration.applicationConfiguration;
if (this.applicationConfiguration) {
localUser = this.localUserConfiguration.reparse({ exclude: application.getValue(APPLY_ALL_PROFILES_SETTING) });
}
await this.loadConfiguration(application, localUser, this._configuration.remoteUserConfiguration, true);
const [localUser, application] = await Promise.all(promises);
await this.loadConfiguration(application ?? this._configuration.applicationConfiguration, localUser, this._configuration.remoteUserConfiguration, true);
})());
}

Expand Down Expand Up @@ -771,35 +758,15 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat

private onApplicationConfigurationChanged(applicationConfiguration: ConfigurationModel): void {
const previous = { data: this._configuration.toData(), workspace: this.workspace };
const previousAllProfilesSettings = this._configuration.applicationConfiguration.getValue<string[]>(APPLY_ALL_PROFILES_SETTING) ?? [];
const change = this._configuration.compareAndUpdateApplicationConfiguration(applicationConfiguration);
const currentAllProfilesSettings = this.getValue<string[]>(APPLY_ALL_PROFILES_SETTING) ?? [];
const configurationProperties = this.configurationRegistry.getConfigurationProperties();
const changedKeys: string[] = [];
for (const changedKey of change.keys) {
if (configurationProperties[changedKey]?.scope === ConfigurationScope.APPLICATION) {
changedKeys.push(changedKey);
if (changedKey === APPLY_ALL_PROFILES_SETTING) {
for (const previousAllProfileSetting of previousAllProfilesSettings) {
if (!currentAllProfilesSettings.includes(previousAllProfileSetting)) {
changedKeys.push(previousAllProfileSetting);
}
}
for (const currentAllProfileSetting of currentAllProfilesSettings) {
if (!previousAllProfilesSettings.includes(currentAllProfileSetting)) {
changedKeys.push(currentAllProfileSetting);
}
}
}
}
else if (currentAllProfilesSettings.includes(changedKey)) {
changedKeys.push(changedKey);
}
}
change.keys = changedKeys;
if (change.keys.includes(APPLY_ALL_PROFILES_SETTING)) {
this._configuration.updateLocalUserConfiguration(this.localUserConfiguration.reparse({ exclude: currentAllProfilesSettings }));
}
this.triggerConfigurationChange(change, previous, ConfigurationTarget.USER);
}

Expand Down Expand Up @@ -1351,18 +1318,3 @@ const workbenchContributionsRegistry = Registry.as<IWorkbenchContributionsRegist
workbenchContributionsRegistry.registerWorkbenchContribution(RegisterConfigurationSchemasContribution, LifecyclePhase.Restored);
workbenchContributionsRegistry.registerWorkbenchContribution(ResetConfigurationDefaultsOverridesCache, LifecyclePhase.Eventually);
workbenchContributionsRegistry.registerWorkbenchContribution(UpdateExperimentalSettingsDefaults, LifecyclePhase.Restored);

const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
configurationRegistry.registerConfiguration({
...workbenchConfigurationNodeBase,
properties: {
[APPLY_ALL_PROFILES_SETTING]: {
'type': 'array',
description: localize('setting description', "Configure settings to be applied for all profiles."),
'default': [],
'scope': ConfigurationScope.APPLICATION,
additionalProperties: true,
uniqueItems: true,
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,3 @@ export interface IWorkbenchConfigurationService extends IConfigurationService {
}

export const TASKS_DEFAULT = '{\n\t\"version\": \"2.0.0\",\n\t\"tasks\": []\n}';

export const APPLY_ALL_PROFILES_SETTING = 'workbench.settings.applyToAllProfiles';
Loading

0 comments on commit 0e623c1

Please sign in to comment.