@@ -68,7 +68,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
68
68
private lastBoardsConfigOnUpload : BoardsConfig . Config | undefined ;
69
69
// "lastPersistingUploadPort", is a port created during an upload, that persisted after
70
70
// 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 ;
72
72
73
73
/**
74
74
* Unlike `onAttachedBoardsChanged` this even fires when the user modifies the selected board in the IDE.\
@@ -124,7 +124,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
124
124
125
125
private derivePersistingUploadPort ( event : AttachedBoardsChangeEvent ) : void {
126
126
if ( ! this . lastBoardsConfigOnUpload ) {
127
- this . lastPersistingUploadPort = undefined ;
127
+ this . lastPersistingUploadPortWithBoard = undefined ;
128
128
return ;
129
129
}
130
130
@@ -160,7 +160,10 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
160
160
lastSelectionOnUpload . selectedBoard &&
161
161
Board . sameAs ( boardOnAppearedPort , lastSelectionOnUpload . selectedBoard )
162
162
) {
163
- this . lastPersistingUploadPort = appearedPorts [ 0 ] ;
163
+ this . lastPersistingUploadPortWithBoard = {
164
+ selectedBoard : boardOnAppearedPort ,
165
+ selectedPort : appearedPorts [ 0 ] ,
166
+ } ;
164
167
return ;
165
168
}
166
169
}
@@ -307,36 +310,11 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
307
310
// If we could not find an exact match, we compare the board FQBN-name pairs and ignore the port, as it might have changed.
308
311
// See documentation on `latestValidBoardsConfig`.
309
312
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 ;
323
314
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 ;
340
318
}
341
319
return false ;
342
320
}
0 commit comments