mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Add manual reset flag for settings update event (#144429)
Ref https://github.com/microsoft/vscode/issues/58038 This flag could also come in useful for language overrides.
This commit is contained in:
parent
4483c082e8
commit
6db78b59f9
|
@ -788,7 +788,7 @@ export class SettingsEditor2 extends EditorPane {
|
|||
private createSettingsTree(container: HTMLElement): void {
|
||||
|
||||
this.settingRenderers = this.instantiationService.createInstance(SettingTreeRenderers);
|
||||
this._register(this.settingRenderers.onDidChangeSetting(e => this.onDidChangeSetting(e.key, e.value, e.type)));
|
||||
this._register(this.settingRenderers.onDidChangeSetting(e => this.onDidChangeSetting(e.key, e.value, e.type, e.manualReset)));
|
||||
this._register(this.settingRenderers.onDidOpenSettings(settingKey => {
|
||||
this.openSettingsFile({ revealSetting: { key: settingKey, edit: true } });
|
||||
}));
|
||||
|
@ -869,16 +869,16 @@ export class SettingsEditor2 extends EditorPane {
|
|||
}));
|
||||
}
|
||||
|
||||
private onDidChangeSetting(key: string, value: any, type: SettingValueType | SettingValueType[]): void {
|
||||
private onDidChangeSetting(key: string, value: any, type: SettingValueType | SettingValueType[], manualReset: boolean): void {
|
||||
if (this.pendingSettingUpdate && this.pendingSettingUpdate.key !== key) {
|
||||
this.updateChangedSetting(key, value);
|
||||
this.updateChangedSetting(key, value, manualReset);
|
||||
}
|
||||
|
||||
this.pendingSettingUpdate = { key, value };
|
||||
if (SettingsEditor2.shouldSettingUpdateFast(type)) {
|
||||
this.settingFastUpdateDelayer.trigger(() => this.updateChangedSetting(key, value));
|
||||
this.settingFastUpdateDelayer.trigger(() => this.updateChangedSetting(key, value, manualReset));
|
||||
} else {
|
||||
this.settingSlowUpdateDelayer.trigger(() => this.updateChangedSetting(key, value));
|
||||
this.settingSlowUpdateDelayer.trigger(() => this.updateChangedSetting(key, value, manualReset));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -948,7 +948,7 @@ export class SettingsEditor2 extends EditorPane {
|
|||
return ancestors.reverse();
|
||||
}
|
||||
|
||||
private updateChangedSetting(key: string, value: any): Promise<void> {
|
||||
private updateChangedSetting(key: string, value: any, manualReset: boolean): Promise<void> {
|
||||
// ConfigurationService displays the error if this fails.
|
||||
// Force a render afterwards because onDidConfigurationUpdate doesn't fire if the update doesn't result in an effective setting value change
|
||||
const settingsTarget = this.settingsTargetsWidget.settingsTarget;
|
||||
|
@ -956,11 +956,13 @@ export class SettingsEditor2 extends EditorPane {
|
|||
const configurationTarget = <ConfigurationTarget>(resource ? ConfigurationTarget.WORKSPACE_FOLDER : settingsTarget);
|
||||
const overrides: IConfigurationOverrides = { resource };
|
||||
|
||||
const isManualReset = value === undefined;
|
||||
const configurationTargetIsWorkspace = configurationTarget === ConfigurationTarget.WORKSPACE || configurationTarget === ConfigurationTarget.WORKSPACE_FOLDER;
|
||||
|
||||
// If the user is changing the value back to the default, do a 'reset' instead
|
||||
const isManualReset = configurationTargetIsWorkspace ? manualReset : value === undefined;
|
||||
|
||||
// If the user is changing the value back to the default, and we're not targeting a workspace scope, do a 'reset' instead
|
||||
const inspected = this.configurationService.inspect(key, overrides);
|
||||
if (inspected.defaultValue === value) {
|
||||
if (!configurationTargetIsWorkspace && inspected.defaultValue === value) {
|
||||
value = undefined;
|
||||
}
|
||||
|
||||
|
|
|
@ -656,6 +656,7 @@ export interface ISettingChangeEvent {
|
|||
key: string;
|
||||
value: any; // undefined => reset/unconfigure
|
||||
type: SettingValueType | SettingValueType[];
|
||||
manualReset: boolean;
|
||||
}
|
||||
|
||||
export interface ISettingLinkClickEvent {
|
||||
|
@ -782,7 +783,7 @@ export abstract class AbstractSettingRenderer extends Disposable implements ITre
|
|||
|
||||
const descriptionElement = DOM.append(container, $('.setting-item-description'));
|
||||
const modifiedIndicatorElement = DOM.append(container, $('.setting-item-modified-indicator'));
|
||||
modifiedIndicatorElement.title = localize('modified', "Modified");
|
||||
modifiedIndicatorElement.title = localize('modified', "The setting has been configured in the current scope.");
|
||||
|
||||
const valueElement = DOM.append(container, $('.setting-item-value'));
|
||||
const controlElement = DOM.append(valueElement, $('div.setting-item-control'));
|
||||
|
@ -883,7 +884,7 @@ export abstract class AbstractSettingRenderer extends Disposable implements ITre
|
|||
|
||||
template.miscLabel.updateOtherOverrides(element, template.elementDisposables, this._onDidClickOverrideElement);
|
||||
|
||||
const onChange = (value: any) => this._onDidChangeSetting.fire({ key: element.setting.key, value, type: template.context!.valueType });
|
||||
const onChange = (value: any) => this._onDidChangeSetting.fire({ key: element.setting.key, value, type: template.context!.valueType, manualReset: false });
|
||||
const deprecationText = element.setting.deprecationMessage || '';
|
||||
if (deprecationText && element.setting.deprecationMessageIsMarkdown) {
|
||||
const disposables = new DisposableStore();
|
||||
|
@ -1449,7 +1450,8 @@ export class SettingExcludeRenderer extends AbstractSettingRenderer implements I
|
|||
this._onDidChangeSetting.fire({
|
||||
key: template.context.setting.key,
|
||||
value: Object.keys(newValue).length === 0 ? undefined : sortKeys(newValue),
|
||||
type: template.context.valueType
|
||||
type: template.context.valueType,
|
||||
manualReset: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1765,7 +1767,7 @@ export class SettingBoolRenderer extends AbstractSettingRenderer implements ITre
|
|||
const controlElement = DOM.append(descriptionAndValueElement, $('.setting-item-bool-control'));
|
||||
const descriptionElement = DOM.append(descriptionAndValueElement, $('.setting-item-description'));
|
||||
const modifiedIndicatorElement = DOM.append(container, $('.setting-item-modified-indicator'));
|
||||
modifiedIndicatorElement.title = localize('modified', "Modified");
|
||||
modifiedIndicatorElement.title = localize('modified', "The setting has been configured in the current scope.");
|
||||
|
||||
|
||||
const deprecationWarningElement = DOM.append(container, $('.setting-item-deprecation-message'));
|
||||
|
@ -1904,7 +1906,7 @@ export class SettingTreeRenderers {
|
|||
new Action('settings.resetSetting', localize('resetSettingLabel', "Reset Setting"), undefined, undefined, async context => {
|
||||
if (context instanceof SettingsTreeSettingElement) {
|
||||
if (!context.isUntrusted) {
|
||||
this._onDidChangeSetting.fire({ key: context.setting.key, value: undefined, type: context.setting.type as SettingValueType });
|
||||
this._onDidChangeSetting.fire({ key: context.setting.key, value: undefined, type: context.setting.type as SettingValueType, manualReset: true });
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
|
Loading…
Reference in a new issue