From bdae02e51efaa4ecabcabb27bbfddcc68bbf5ad2 Mon Sep 17 00:00:00 2001 From: kisantia <31145923+kisantia@users.noreply.github.com> Date: Wed, 22 May 2019 16:42:02 -0700 Subject: [PATCH] fix default server not being chosen (#5583) --- .../src/dialogs/schemaCompareDialog.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/extensions/schema-compare/src/dialogs/schemaCompareDialog.ts b/extensions/schema-compare/src/dialogs/schemaCompareDialog.ts index 15a9d9d057..3236ab5426 100644 --- a/extensions/schema-compare/src/dialogs/schemaCompareDialog.ts +++ b/extensions/schema-compare/src/dialogs/schemaCompareDialog.ts @@ -441,6 +441,9 @@ export class SchemaCompareDialog { return undefined; } + // reverse list so that most recent connections are first + cons.reverse(); + let count = -1; let idx = -1; let values = cons.map(c => { @@ -465,6 +468,13 @@ export class SchemaCompareDialog { }; }); + // move server of current connection to the top of the list so it is the default + if (idx >= 1) { + let tmp = values[0]; + values[0] = values[idx]; + values[idx] = tmp; + } + values = values.reduce((uniqueValues, conn) => { let exists = uniqueValues.find(x => x.displayName === conn.displayName); if (!exists) { @@ -473,16 +483,6 @@ export class SchemaCompareDialog { return uniqueValues; }, []); - // reverse list so that most recent connections show first - values.reverse(); - - // move server of current connection to the top of the list so it is the default - if (idx >= 1) { - let tmp = values[0]; - values[0] = values[idx]; - values[idx] = tmp; - } - return values; }