Fixing dup connections (#22670)

This commit is contained in:
Aasim Khan
2023-04-11 14:16:59 -07:00
committed by GitHub
parent 4d3d74e3da
commit 577d99e790

View File

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