From 760ccfdef3bbd060c7c4b6206612baf6dcb30367 Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Wed, 19 Jul 2023 15:42:56 -0700 Subject: [PATCH] Removing unnecessary tree expansions causing errors to popup again (#23932) --- .../objectExplorer/browser/serverTreeView.ts | 8 -------- .../objectExplorer/browser/asyncServerTree.ts | 15 +++------------ 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts index 49d4028ce0..baf5fe9a94 100644 --- a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts +++ b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts @@ -332,8 +332,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView { const movedConnection = e.source; const oldParent = this._tree.getElementById(e.oldGroupId); const newParent = this._tree.getElementById(e.newGroupId); - // Storing the expanded state of children of the moved connection so that they can be expanded after the move. - const profileExpandedState = this._tree.getExpandedState(movedConnection); if (oldParent) { oldParent.removeConnections([movedConnection]); await this._tree.updateChildren(oldParent); @@ -348,8 +346,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView { const newConnection = this._tree.getElementById(movedConnection.id); if (newConnection) { await this._tree.revealSelectFocusElement(newConnection); - // Expanding the previously expanded children of the moved connection after the move. - await this._tree.expandElements(profileExpandedState); } } })); @@ -401,8 +397,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView { const movedGroup = e.source; const oldParent = this._tree.getElementById(e.oldGroupId); const newParent = this._tree.getElementById(e.newGroupId); - // Storing the expanded state of children of the moved group so that they can be expanded after the move. - const profileExpandedState = this._tree.getExpandedState(movedGroup); oldParent.children = oldParent.children.filter(c => c.id !== movedGroup.id); await this._tree.updateChildren(oldParent); newParent.children.push(movedGroup); @@ -410,8 +404,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView { (movedGroup).parentId = newParent.id; await this._tree.updateChildren(newParent); await this._tree.revealSelectFocusElement(movedGroup); - // Expanding the previously expanded children of the moved group after the move. - this._tree.expandElements(profileExpandedState); } })); diff --git a/src/sql/workbench/services/objectExplorer/browser/asyncServerTree.ts b/src/sql/workbench/services/objectExplorer/browser/asyncServerTree.ts index 45787e0944..db42c5f020 100644 --- a/src/sql/workbench/services/objectExplorer/browser/asyncServerTree.ts +++ b/src/sql/workbench/services/objectExplorer/browser/asyncServerTree.ts @@ -120,19 +120,10 @@ export class AsyncServerTree extends WorkbenchAsyncDataTree): Promise { - const expandedChildren = this.getExpandedState(element); + public override async updateChildren(element?: ServerTreeElement, recursive: boolean = false, rerender: boolean = false, options: IAsyncDataTreeUpdateChildrenOptions = { + diffDepth: 0 + }): Promise { await super.updateChildren(element, recursive, rerender, options); - await this.expandElements(expandedChildren); - } - - public async expandElements(elements: ServerTreeElement[]): Promise { - for (let element of elements) { - const node = this.getDataNode(element, false); - if (node) { - await this.expand(node.element); - } - } } /**