Skip to content

Commit c60f4c3

Browse files
fix: repl: Always select a file when calling workspace.set() (#1297)
repl: Always select a file when calling workspace.set() This might fix #1287, #868, etc. Co-authored-by: Tee Ming <chewteeming01@gmail.com>
1 parent 8c8603d commit c60f4c3

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

packages/repl/src/lib/Workspace.svelte.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,9 @@ export class Workspace {
425425
throw new Error('Workspace must have at least one file');
426426
}
427427

428-
if (selected) {
429-
const file = files.find((file) => is_file(file) && file.name === selected);
430-
431-
if (!file) {
432-
throw new Error(`Invalid selection ${selected}`);
433-
}
434-
this.#select(file as File);
428+
const matching_file = selected && files.find((file) => is_file(file) && file.name === selected);
429+
if (matching_file) {
430+
this.#select(matching_file as File);
435431
} else {
436432
this.#select(first);
437433
}

0 commit comments

Comments
 (0)
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