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

Fix default override model value #150232

Merged
merged 1 commit into from
May 24, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class SettingsTreeIndicatorsLabel {

updateDefaultOverrideIndicator(element: SettingsTreeSettingElement) {
this.defaultOverrideIndicatorElement.style.display = 'none';
const defaultValueSource = element.setting.defaultValueSource;
const defaultValueSource = element.defaultValueSource;
if (defaultValueSource) {
this.defaultOverrideIndicatorElement.style.display = 'inline';
if (typeof defaultValueSource !== 'string' && defaultValueSource.id !== element.setting.extensionInfo?.id) {
Expand Down Expand Up @@ -157,8 +157,8 @@ export function getIndicatorsLabelAriaLabel(element: SettingsTreeSettingElement,
}

// Add default override indicator text
if (element.setting.defaultValueSource) {
const defaultValueSource = element.setting.defaultValueSource;
if (element.defaultValueSource) {
const defaultValueSource = element.defaultValueSource;
if (typeof defaultValueSource !== 'string' && defaultValueSource.id !== element.setting.extensionInfo?.id) {
const extensionSource = defaultValueSource.displayName ?? defaultValueSource.id;
ariaLabelSections.push(localize('defaultOverriddenDetails', "Default setting value overridden by {0}", extensionSource));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ export class SettingComplexRenderer extends AbstractSettingRenderer implements I

template.elementDisposables.add(template.button.onDidClick(() => {
if (isLanguageTagSetting) {
this._onApplyFilter.fire(`@${LANGUAGE_SETTING_TAG}:${plainKey}`);
this._onApplyFilter.fire(`@${LANGUAGE_SETTING_TAG}${plainKey}`);
} else {
this._onDidOpenSettings.fire(dataElement.setting.key);
}
Expand Down
19 changes: 17 additions & 2 deletions src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { FOLDER_SCOPES, WORKSPACE_SCOPES, REMOTE_MACHINE_SCOPES, LOCAL_MACHINE_S
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { Disposable } from 'vs/base/common/lifecycle';
import { Emitter } from 'vs/base/common/event';
import { ConfigurationScope, EditPresentationTypes, Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
import { ConfigurationScope, EditPresentationTypes, Extensions, IConfigurationRegistry, IExtensionInfo } from 'vs/platform/configuration/common/configurationRegistry';
import { ILanguageService } from 'vs/editor/common/languages/language';
import { Registry } from 'vs/platform/registry/common/platform';

Expand Down Expand Up @@ -129,6 +129,12 @@ export class SettingsTreeSettingElement extends SettingsTreeElement {
*/
defaultValue?: any;

/**
* The source of the default value to display.
* This value also accounts for extension-contributed language-specific default value overrides.
*/
defaultValueSource: string | IExtensionInfo | undefined;

/**
* Whether the setting is configured in the selected scope.
*/
Expand All @@ -146,7 +152,12 @@ export class SettingsTreeSettingElement extends SettingsTreeElement {

tags?: Set<string>;
overriddenScopeList: string[] = [];

/**
* For each language that contributes setting values or default overrides, we can see those values here.
*/
languageOverrideValues: Map<string, IConfigurationValue<unknown>> = new Map<string, IConfigurationValue<unknown>>();

description!: string;
valueType!: SettingValueType;

Expand Down Expand Up @@ -219,6 +230,10 @@ export class SettingsTreeSettingElement extends SettingsTreeElement {
}
}

// The user might have added, removed, or modified a language filter,
// so we reset the default value source to the non-language-specific default value source for now.
this.defaultValueSource = this.setting.nonLanguageSpecificDefaultValueSource;

if (inspected.policyValue) {
this.hasPolicyValue = true;
isConfigured = false; // The user did not manually configure the setting themselves.
Expand All @@ -236,7 +251,7 @@ export class SettingsTreeSettingElement extends SettingsTreeElement {
const registryValues = Registry.as<IConfigurationRegistry>(Extensions.Configuration).getConfigurationDefaultsOverrides();
const overrideValueSource = registryValues.get(`[${languageSelector}]`)?.valuesSources?.get(this.setting.key);
if (overrideValueSource) {
this.setting.defaultValueSource = overrideValueSource;
this.defaultValueSource = overrideValueSource;
}
} else {
this.scopeValue = isConfigured && inspected[targetSelector];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export interface ISetting {
enumItemLabels?: string[];
allKeysAreBoolean?: boolean;
editPresentation?: EditPresentationTypes;
defaultValueSource?: string | IExtensionInfo;
nonLanguageSpecificDefaultValueSource?: string | IExtensionInfo;
isLanguageTagSetting?: boolean;
categoryOrder?: number;
categoryLabel?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ export class DefaultSettings extends Disposable {
allKeysAreBoolean,
editPresentation: prop.editPresentation,
order: prop.order,
defaultValueSource,
nonLanguageSpecificDefaultValueSource: defaultValueSource,
isLanguageTagSetting,
categoryLabel,
categoryOrder
Expand Down