From 655588891cd2cafd45f2f5bf7424ad98c6b05f92 Mon Sep 17 00:00:00 2001 From: Sakshi Sharma <57200045+SakshiS-harma@users.noreply.github.com> Date: Thu, 26 Jan 2023 14:44:02 -0800 Subject: [PATCH] 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 --- .../src/dialogs/schemaCompareDialog.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/extensions/schema-compare/src/dialogs/schemaCompareDialog.ts b/extensions/schema-compare/src/dialogs/schemaCompareDialog.ts index d35a0f54f0..14337cc54e 100644 --- a/extensions/schema-compare/src/dialogs/schemaCompareDialog.ts +++ b/extensions/schema-compare/src/dialogs/schemaCompareDialog.ts @@ -88,7 +88,7 @@ export class SchemaCompareDialog { // connection to use if schema compare wasn't launched from a database or no previous source/target let connection = await azdata.connection.getCurrentConnection(); if (connection) { - this.connectionId = connection.connectionId; + this.connectionId = connection.connectionId; // current active connection } this.dialog = azdata.window.createModelViewDialog(loc.SchemaCompareLabel); @@ -874,13 +874,12 @@ export class SchemaCompareDialog { finalName = c.options.connectionName; } - // use previously selected server or current connection if there is one - if (endpointInfo && !isNullOrUndefined(endpointInfo.serverName) && !isNullOrUndefined(endpointInfo.serverDisplayName) - && c.options.server.toLowerCase() === endpointInfo.serverName.toLowerCase() - && finalName.toLowerCase() === endpointInfo.serverDisplayName.toLowerCase()) { - idx = count; - } - else if (c.connectionId === this.connectionId) { + // use current connection else use previously selected server if there is one + if ((c.connectionId === this.connectionId) || + (endpointInfo && !isNullOrUndefined(endpointInfo.serverName) && !isNullOrUndefined(endpointInfo.serverDisplayName) + && c.options.server.toLowerCase() === endpointInfo.serverName.toLowerCase() + && finalName.toLowerCase() === endpointInfo.serverDisplayName.toLowerCase() + && idx === -1)) { // select previous server only if current connection hasn't been set already idx = count; }