From 1efe948abef7d27474d002547e8f9292876fe43f Mon Sep 17 00:00:00 2001 From: Benjin Dubishar Date: Thu, 18 May 2023 10:30:58 -0700 Subject: [PATCH] Finding index is correct array (#23162) --- .../src/dialogs/publishDatabaseQuickpick.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts b/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts index 47186080a2..68f9640c1e 100644 --- a/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts +++ b/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts @@ -127,14 +127,13 @@ export async function getPublishDatabaseSettings(project: ISqlProject, promptFor // if a publish profile was loaded and had a database name, use that instead of the project file name const dbName = publishProfile?.databaseName || project.projectFileName; - // Ensure the project name or name specified in the publish profile is an option, either adding it if it - // doesn't already exist or moving it to the top if it does - const projectNameIndex = dbs.findIndex(db => db === dbName); - if (projectNameIndex === -1) { + // Ensure the project name or name specified in the publish profile is an option + const projectNameIndex = dbQuickpicks.findIndex(db => db.label === dbName); + if (projectNameIndex === -1) { // add it if it doesn't already exist... dbQuickpicks.unshift({ label: dbName, description: constants.newText }); - } else { - dbQuickpicks.splice(projectNameIndex, 1); - dbQuickpicks.unshift({ label: dbName }); + } else { // ...or move it to the top if it does + const removed = dbQuickpicks.splice(projectNameIndex, 1)[0]; + dbQuickpicks.unshift(removed); } let databaseName: string | undefined = undefined;