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);