Skip to content

Commit

Permalink
fix(regression): find board match in dialog
Browse files Browse the repository at this point in the history
when platform is not installed

Ref: #2149 (comment)
Signed-off-by: Akos Kitta <[email protected]>
  • Loading branch information
Akos Kitta committed Jul 26, 2023
1 parent e9004b0 commit 82d3c34
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions arduino-ide-extension/src/common/protocol/boards-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit 82d3c34

Please sign in to comment.