diff --git a/arduino-ide-extension/src/common/protocol/boards-service.ts b/arduino-ide-extension/src/common/protocol/boards-service.ts index 42bc75c7e..9f0aed1c6 100644 --- a/arduino-ide-extension/src/common/protocol/boards-service.ts +++ b/arduino-ide-extension/src/common/protocol/boards-service.ts @@ -522,7 +522,13 @@ export namespace Board { const counter = distinctBoardNames.get(name) || 0; distinctBoardNames.set(name, counter + 1); } - + let selectedBoardPackageId: string | undefined = undefined; + if (selectedBoard?.fqbn) { + selectedBoardPackageId = selectedBoard.fqbn + .split(':') + .slice(0, 2) + .join(':'); + } // Due to the non-unique board names, we have to check the package name as well. const selected = (board: BoardWithPackage) => { if (!!selectedBoard) { @@ -532,15 +538,13 @@ export namespace Board { selectedBoard ) ) { - // TODO: this won't work anymore with the current BoardIdentifier as it does not contain the container packager info. - // Possible duplicate items in board select dialog for non-installed boards from different platforms. - if ('packageName' in selectedBoard) { - return board.packageName === (selectedBoard as any).packageName; + if (selectedBoardPackageId) { + return board.packageId === selectedBoardPackageId; } - if ('packageId' in selectedBoard) { - return board.packageId === (selectedBoard as any).packageId; + if (!board.fqbn && board.name === selectedBoard.name) { + return true; } - return true; + return false; } } return false;