File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -429,7 +429,23 @@ export class Workspace {
429429 if ( matching_file ) {
430430 this . #select( matching_file as File ) ;
431431 } else {
432- this . #select( first ) ;
432+ // Try to select the first file in the file selector thing.
433+ // The file selector lists files in the root directory after all files in
434+ // other directories.
435+ const top_file = files . filter ( is_file ) . sort ( ( a , b ) => {
436+ const in_root_dir = x => x . basename === x . name
437+
438+ if ( in_root_dir ( a ) != in_root_dir ( b ) ) {
439+ return in_root_dir ( a ) - in_root_dir ( b )
440+ } else if ( a . name < b . name ) {
441+ return - 1
442+ } else if ( a . name > b . name ) {
443+ return 1
444+ else {
445+ return 0
446+ }
447+ } ) [ 0 ]
448+ this . #select( top_file ) ;
433449 }
434450
435451 this . #files = files ;
You can’t perform that action at this time.
0 commit comments