From 59bab00373bef2030d499177a7c772cfce94a0d5 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Mon, 15 Apr 2024 14:22:14 -0700 Subject: [PATCH] hoist current binary --- extension/src/flow-cli/cli-selection-provider.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/extension/src/flow-cli/cli-selection-provider.ts b/extension/src/flow-cli/cli-selection-provider.ts index 16486d50..eb2364ee 100644 --- a/extension/src/flow-cli/cli-selection-provider.ts +++ b/extension/src/flow-cli/cli-selection-provider.ts @@ -82,16 +82,16 @@ export class CliSelectionProvider { // Update available versions const items: Array = availableBinaries.map(binary => new AvailableBinaryItem(binary)) items.push(new CustomBinaryItem()) - versionSelector.items = items - // Select the current binary - if (currentBinary !== null) { - const currentBinaryItem = versionSelector.items.find(item => item instanceof AvailableBinaryItem && item.path === currentBinary.path) - if (currentBinaryItem != null) { - versionSelector.selectedItems = [currentBinaryItem] - } + // Hoist the current binary to the top of the list + const currentBinaryIndex = items.findIndex(item => item instanceof AvailableBinaryItem && item.path === currentBinary?.path) + if (currentBinaryIndex != null) { + const currentBinaryItem = items[currentBinaryIndex] + items.splice(currentBinaryIndex, 1) + items.unshift(currentBinaryItem) } + versionSelector.items = items return versionSelector }