diff --git a/packages/repl/src/lib/Workspace.svelte.ts b/packages/repl/src/lib/Workspace.svelte.ts index 714f277a09..2cc0bfce05 100644 --- a/packages/repl/src/lib/Workspace.svelte.ts +++ b/packages/repl/src/lib/Workspace.svelte.ts @@ -429,7 +429,23 @@ export class Workspace { if (matching_file) { this.#select(matching_file as File); } else { - this.#select(first); + // Try to select the first file in the file selector thing. + // The file selector lists files in the root directory after all files in + // other directories. + const top_file = files.filter(is_file).sort((a, b) => { + const in_root_dir = x => x.basename === x.name + + if (in_root_dir(a) != in_root_dir(b)) { + return in_root_dir(a) - in_root_dir(b) + } else if (a.name < b.name) { + return -1 + } else if (a.name > b.name) { + return 1 + else { + return 0 + } + })[0] + this.#select(top_file); } this.#files = files; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy