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: refresh single element when element is known #220126

Merged
merged 1 commit into from
Jul 9, 2024
Merged
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
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
Loading