Skip to content

Commit de4ae23

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
Fixed boards config update on core uninstall.
From now on, we avoid discarding the FQBN of the selected board if it was attached and recognized. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent 5a57576 commit de4ae23

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

arduino-ide-extension/src/browser/boards/boards-service-provider.ts

+11
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
139139
if (selectedBoard && selectedBoard.fqbn) {
140140
const uninstalledBoard = event.item.boards.find(({ name }) => name === selectedBoard.name);
141141
if (uninstalledBoard && uninstalledBoard.fqbn === selectedBoard.fqbn) {
142+
// We should not unset the FQBN, if the selected board is an attached, recognized board.
143+
// Attach Uno and install AVR, select Uno. Uninstall the AVR core while Uno is selected. We do not want to discard the FQBN of the Uno board.
144+
// Dev note: We cannot assume the `selectedBoard` is a type of `AvailableBoard`.
145+
// When the user selects an `AvailableBoard` it works, but between app start/stops,
146+
// it is just a FQBN, so we need to find the `selected` board among the `AvailableBoards`
147+
const selectedAvailableBoard = AvailableBoard.is(selectedBoard)
148+
? selectedBoard
149+
: this._availableBoards.find(availableBoard => Board.sameAs(availableBoard, selectedBoard));
150+
if (selectedAvailableBoard && selectedAvailableBoard.selected && selectedAvailableBoard.state === AvailableBoard.State.recognized) {
151+
return;
152+
}
142153
this.logger.info(`Board package ${event.item.id} was uninstalled. Discarding the FQBN of the currently selected ${selectedBoard.name} board.`);
143154
const selectedBoardWithoutFqbn = {
144155
name: selectedBoard.name

0 commit comments

Comments
 (0)