From 577d99e7906a2e630df94ef1deb37c3f4a8dbae6 Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Tue, 11 Apr 2023 14:16:59 -0700 Subject: [PATCH] Fixing dup connections (#22670) --- .../contrib/objectExplorer/browser/serverTreeView.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts index 2b9145a1be..7b585eb65a 100644 --- a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts +++ b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts @@ -228,7 +228,12 @@ export class ServerTreeView extends Disposable implements IServerTreeView { if (this._tree instanceof AsyncServerTree) { const connectionParentGroup = this._tree.getElementById(newConnection.groupId) as ConnectionProfileGroup; if (connectionParentGroup) { - connectionParentGroup.connections.push(newConnection); + const matchingConnectionIndex = connectionParentGroup.connections.findIndex((connection) => connection.matches(newConnection)); + if (matchingConnectionIndex !== -1) { + connectionParentGroup.connections[matchingConnectionIndex] = newConnection; + } else { + connectionParentGroup.connections.push(newConnection); + } newConnection.parent = connectionParentGroup; newConnection.groupId = connectionParentGroup.id; await this._tree.updateChildren(connectionParentGroup);