Skip to content

Commit

Permalink
fix: refresh single element when element is known (#220126)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhao271 authored Jul 9, 2024
1 parent 4e928f7 commit 316c67d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1408,9 +1408,7 @@ export class SettingsEditor2 extends EditorPane {
keys.forEach(key => this.settingsTreeModel.updateElementsByName(key));
}

// Attempt to render the tree once rather than
// once for each key to avoid redundant calls to this.refreshTree()
this.renderTree();
keys.forEach(key => this.renderTree(key));
} else {
this.renderTree();
}
Expand Down Expand Up @@ -1450,7 +1448,6 @@ export class SettingsEditor2 extends EditorPane {
// update `list`s live, as they have a separate "submit edit" step built in before this
(focusedSetting.parentElement && !focusedSetting.parentElement.classList.contains('setting-item-list'))
) {

this.updateModifiedLabelForKey(key);
this.scheduleRefresh(focusedSetting, key);
return;
Expand All @@ -1466,8 +1463,10 @@ export class SettingsEditor2 extends EditorPane {
if (key) {
const elements = this.currentSettingsModel.getElementsByName(key);
if (elements && elements.length) {
// TODO https://github.com/microsoft/vscode/issues/57360
this.refreshTree();
if (elements.length >= 2) {
console.warn('More than one setting with key ' + key + ' found');
}
this.refreshSingleElement(elements[0]);
} else {
// Refresh requested for a key that we don't know about
return;
Expand All @@ -1483,6 +1482,12 @@ export class SettingsEditor2 extends EditorPane {
return !!DOM.findParentWithClass(<HTMLElement>this.rootElement.ownerDocument.activeElement, 'context-view');
}

private refreshSingleElement(element: SettingsTreeSettingElement): void {
if (this.isVisible()) {
this.settingsTree.rerender(element);
}
}

private refreshTree(): void {
if (this.isVisible()) {
this.settingsTree.setChildren(null, createGroupIterator(this.currentSettingsModel.root));
Expand Down

0 comments on commit 316c67d

Please sign in to comment.