File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
ui/arduino/views/components Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,18 @@ function generateFileList(source) {
92
92
}
93
93
94
94
// XXX: Use `source` to filter an array of files with a `source` as proprety
95
+ const files = state [ `${ source } Files` ] . sort ( ( a , b ) => {
96
+ const nameA = a . fileName . toUpperCase ( )
97
+ const nameB = b . fileName . toUpperCase ( )
98
+ // Folders come first than files
99
+ if ( a . type === 'folder' && b . type === 'file' ) return - 1
100
+ // Folders and files come in alphabetic order
101
+ if ( a . type === b . type ) {
102
+ if ( nameA < nameB ) return - 1
103
+ if ( nameA > nameB ) return 1
104
+ }
105
+ return 0
106
+ } )
95
107
const list = html `
96
108
< div class ="file-list ">
97
109
< div class ="list ">
@@ -103,7 +115,7 @@ function generateFileList(source) {
103
115
</ div >
104
116
${ state . creatingFile == source ? newFileItem : null }
105
117
${ state . creatingFolder == source ? newFolderItem : null }
106
- ${ state [ ` ${ source } Files` ] . map ( FileItem ) }
118
+ ${ files . map ( FileItem ) }
107
119
</ div >
108
120
</ div >
109
121
`
You can’t perform that action at this time.
0 commit comments