Skip to content

Commit d55cd18

Browse files
cleanup
1 parent c3868c6 commit d55cd18

File tree

1 file changed

+10
-32
lines changed

1 file changed

+10
-32
lines changed

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

+10-32
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
6868
private lastBoardsConfigOnUpload: BoardsConfig.Config | undefined;
6969
// "lastPersistingUploadPort", is a port created during an upload, that persisted after
7070
// the upload finished, it's "substituting" the port selected when the user invoked the upload
71-
private lastPersistingUploadPort: Port | undefined;
71+
private lastPersistingUploadPortWithBoard: BoardsConfig.Config | undefined;
7272

7373
/**
7474
* Unlike `onAttachedBoardsChanged` this even fires when the user modifies the selected board in the IDE.\
@@ -124,7 +124,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
124124

125125
private derivePersistingUploadPort(event: AttachedBoardsChangeEvent): void {
126126
if (!this.lastBoardsConfigOnUpload) {
127-
this.lastPersistingUploadPort = undefined;
127+
this.lastPersistingUploadPortWithBoard = undefined;
128128
return;
129129
}
130130

@@ -160,7 +160,10 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
160160
lastSelectionOnUpload.selectedBoard &&
161161
Board.sameAs(boardOnAppearedPort, lastSelectionOnUpload.selectedBoard)
162162
) {
163-
this.lastPersistingUploadPort = appearedPorts[0];
163+
this.lastPersistingUploadPortWithBoard = {
164+
selectedBoard: boardOnAppearedPort,
165+
selectedPort: appearedPorts[0],
166+
};
164167
return;
165168
}
166169
}
@@ -307,36 +310,11 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
307310
// If we could not find an exact match, we compare the board FQBN-name pairs and ignore the port, as it might have changed.
308311
// See documentation on `latestValidBoardsConfig`.
309312

310-
if (!this.lastPersistingUploadPort) return false;
311-
312-
const lastPersistingUploadPort = this.lastPersistingUploadPort;
313-
this.lastPersistingUploadPort = undefined;
314-
315-
if (
316-
!Port.sameAs(
317-
lastPersistingUploadPort,
318-
this.latestValidBoardsConfig.selectedPort
319-
)
320-
) {
321-
return false;
322-
}
313+
if (!this.lastPersistingUploadPortWithBoard) return false;
323314

324-
for (const board of this.availableBoards.filter(
325-
({ state }) => state !== AvailableBoard.State.incomplete
326-
)) {
327-
if (
328-
this.latestValidBoardsConfig.selectedBoard.fqbn === board.fqbn &&
329-
this.latestValidBoardsConfig.selectedBoard.name === board.name &&
330-
this.latestValidBoardsConfig.selectedPort.protocol ===
331-
board.port?.protocol
332-
) {
333-
this.boardsConfig = {
334-
...this.latestValidBoardsConfig,
335-
selectedPort: board.port,
336-
};
337-
return true;
338-
}
339-
}
315+
this.boardsConfig = this.lastPersistingUploadPortWithBoard;
316+
this.lastPersistingUploadPortWithBoard = undefined;
317+
return true;
340318
}
341319
return false;
342320
}

0 commit comments

Comments
 (0)