@@ -199,14 +199,15 @@ PID: ${PID}`;
199
199
} ) ;
200
200
201
201
// Installed boards
202
- for ( const board of installedBoards ) {
202
+ installedBoards . forEach ( ( board , index ) => {
203
203
const { packageId, packageName, fqbn, name, manuallyInstalled } = board ;
204
204
205
205
const packageLabel =
206
206
packageName +
207
- `${ manuallyInstalled
208
- ? nls . localize ( 'arduino/board/inSketchbook' , ' (in Sketchbook)' )
209
- : ''
207
+ `${
208
+ manuallyInstalled
209
+ ? nls . localize ( 'arduino/board/inSketchbook' , ' (in Sketchbook)' )
210
+ : ''
210
211
} `;
211
212
// Platform submenu
212
213
const platformMenuPath = [ ...boardsPackagesGroup , packageId ] ;
@@ -239,14 +240,18 @@ PID: ${PID}`;
239
240
} ;
240
241
241
242
// Board menu
242
- const menuAction = { commandId : id , label : name } ;
243
+ const menuAction = {
244
+ commandId : id ,
245
+ label : name ,
246
+ order : String ( index ) . padStart ( 4 ) , // pads with leading zeros for alphanumeric sort where order is 1, 2, 11, and NOT 1, 11, 2
247
+ } ;
243
248
this . commandRegistry . registerCommand ( command , handler ) ;
244
249
this . toDisposeBeforeMenuRebuild . push (
245
250
Disposable . create ( ( ) => this . commandRegistry . unregisterCommand ( command ) )
246
251
) ;
247
252
this . menuModelRegistry . registerMenuAction ( platformMenuPath , menuAction ) ;
248
253
// Note: we do not dispose the menu actions individually. Calling `unregisterSubmenu` on the parent will wipe the children menu nodes recursively.
249
- }
254
+ } ) ;
250
255
251
256
// Installed ports
252
257
const registerPorts = (
@@ -282,11 +287,13 @@ PID: ${PID}`;
282
287
283
288
// First we show addresses with recognized boards connected,
284
289
// then all the rest.
285
- const sortedIDs = Object . keys ( ports ) . sort ( ( left : string , right : string ) : number => {
286
- const [ , leftBoards ] = ports [ left ] ;
287
- const [ , rightBoards ] = ports [ right ] ;
288
- return rightBoards . length - leftBoards . length ;
289
- } ) ;
290
+ const sortedIDs = Object . keys ( ports ) . sort (
291
+ ( left : string , right : string ) : number => {
292
+ const [ , leftBoards ] = ports [ left ] ;
293
+ const [ , rightBoards ] = ports [ right ] ;
294
+ return rightBoards . length - leftBoards . length ;
295
+ }
296
+ ) ;
290
297
291
298
for ( let i = 0 ; i < sortedIDs . length ; i ++ ) {
292
299
const portID = sortedIDs [ i ] ;
@@ -322,7 +329,7 @@ PID: ${PID}`;
322
329
const menuAction = {
323
330
commandId : id ,
324
331
label,
325
- order : ` ${ protocolOrder + i + 1 } ` ,
332
+ order : String ( protocolOrder + i + 1 ) . padStart ( 4 ) ,
326
333
} ;
327
334
this . commandRegistry . registerCommand ( command , handler ) ;
328
335
this . toDisposeBeforeMenuRebuild . push (
@@ -354,7 +361,7 @@ PID: ${PID}`;
354
361
}
355
362
356
363
protected async installedBoards ( ) : Promise < InstalledBoardWithPackage [ ] > {
357
- const allBoards = await this . boardsService . searchBoards ( { } ) ;
364
+ const allBoards = await this . boardsService . getInstalledBoards ( ) ;
358
365
return allBoards . filter ( InstalledBoardWithPackage . is ) ;
359
366
}
360
367
}
0 commit comments