From 029fdce30c6f99a6b25f679af521775606c2fa2d Mon Sep 17 00:00:00 2001 From: Colin Caine Date: Thu, 22 May 2025 15:42:17 +0100 Subject: [PATCH] feat: repl: Select top file in file UI when we can't match Follows up on #1297. --- packages/repl/src/lib/Workspace.svelte.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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