Set current connection as the selected connection in schema compare dialog (#21682)

* Set current connection as the selected connection in schema compare dialog

* Address comment
This commit is contained in:
Sakshi Sharma
2023-01-26 14:44:02 -08:00
committed by GitHub
parent f2f3d1c4ef
commit 655588891c

View File

@@ -88,7 +88,7 @@ export class SchemaCompareDialog {
// connection to use if schema compare wasn't launched from a database or no previous source/target // connection to use if schema compare wasn't launched from a database or no previous source/target
let connection = await azdata.connection.getCurrentConnection(); let connection = await azdata.connection.getCurrentConnection();
if (connection) { if (connection) {
this.connectionId = connection.connectionId; this.connectionId = connection.connectionId; // current active connection
} }
this.dialog = azdata.window.createModelViewDialog(loc.SchemaCompareLabel); this.dialog = azdata.window.createModelViewDialog(loc.SchemaCompareLabel);
@@ -874,13 +874,12 @@ export class SchemaCompareDialog {
finalName = c.options.connectionName; finalName = c.options.connectionName;
} }
// use previously selected server or current connection if there is one // use current connection else use previously selected server if there is one
if (endpointInfo && !isNullOrUndefined(endpointInfo.serverName) && !isNullOrUndefined(endpointInfo.serverDisplayName) if ((c.connectionId === this.connectionId) ||
(endpointInfo && !isNullOrUndefined(endpointInfo.serverName) && !isNullOrUndefined(endpointInfo.serverDisplayName)
&& c.options.server.toLowerCase() === endpointInfo.serverName.toLowerCase() && c.options.server.toLowerCase() === endpointInfo.serverName.toLowerCase()
&& finalName.toLowerCase() === endpointInfo.serverDisplayName.toLowerCase()) { && finalName.toLowerCase() === endpointInfo.serverDisplayName.toLowerCase()
idx = count; && idx === -1)) { // select previous server only if current connection hasn't been set already
}
else if (c.connectionId === this.connectionId) {
idx = count; idx = count;
} }