Skip to content

Commit 502e904

Browse files
Akos Kittajbicker
Akos Kitta
authored andcommitted
fine tuned selectedPort update
based on the detached boards. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent 66f429c commit 502e904

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arduino-ide-extension/src/browser/boards/boards-service-client-impl.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ export class BoardsServiceClientImpl implements BoardsServiceClient {
3030

3131
notifyAttachedBoardsChanged(event: AttachedBoardsChangeEvent): void {
3232
this.logger.info('Attached boards changed: ', JSON.stringify(event));
33-
const { boards } = event.newState;
33+
const detachedBoards = AttachedBoardsChangeEvent.diff(event).detached.filter(AttachedSerialBoard.is).map(({ port }) => port);
3434
const { selectedPort, selectedBoard } = this.boardsConfig;
3535
this.onAttachedBoardsChangedEmitter.fire(event);
36-
// Dynamically unset the port if there is not corresponding attached boards for it.
37-
if (!!selectedPort && boards.filter(AttachedSerialBoard.is).map(({ port }) => port).indexOf(selectedPort) === -1) {
36+
// Dynamically unset the port if the selected board was an attached one and we detached it.
37+
if (!!selectedPort && detachedBoards.indexOf(selectedPort) === -1) {
3838
this.boardsConfig = {
3939
selectedBoard,
4040
selectedPort: undefined

0 commit comments

Comments
 (0)