The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.
TypeScript code-editorcross-platformdapdatabase-clientdebuggerdesktop-appdeveloper-toolsgithttp-clientideintellijlsprusttauriterminal
feat(project-view): restore the persisted expansion state as the user left it (#782)
ntbang090147f68862c8bd
diff --git a/src/features/project-tree/store.test.ts b/src/features/project-tree/store.test.tsindex 032924c3e..8d60d4d89 100644--- a/src/features/project-tree/store.test.ts+++ b/src/features/project-tree/store.test.ts@@ -68,6 +68,14 @@ describe("lazy loading", () => {expect([...useProjectTree.getState().expanded].sort()).toEqual(["/p", "/p/docs"]);});+ it("keeps a collapsed project root collapsed and an expanded node outside it open", async () => {+ setExpanded(new Set(["/other/lib"]));+ await new Promise((r) => setTimeout(r, 350));+ initProjectTree(null);+ initProjectTree(ROOT, "proj");+ expect([...useProjectTree.getState().expanded]).toEqual(["/other/lib"]);+ });+it("drops a folder that vanished and collapses it", async () => {await loadDir(ROOT);setExpanded(new Set([ROOT, "/p/gone"]));diff --git a/src/features/project-tree/store.ts b/src/features/project-tree/store.tsindex 3d90bfcb2..cca259ea9 100644--- a/src/features/project-tree/store.ts+++ b/src/features/project-tree/store.ts@@ -301,11 +301,12 @@ function initialExpanded(root: string | null, mode: ViewMode, members = get().mer.scope === "scratches" && r.path ? [r.path] : [],),);- const persisted = mode === "project" ? (readJson<string[]>(expandedKey(root)) ?? []) : [];- const roots = members ?? [root];- const expanded = new Set(persisted.filter((p) => roots.some((r) => isSameOrInside(p, r))));- roots.forEach((r) => expanded.add(r));- return expanded;+ // The tree as the user left it, like IDEA: a collapsed project root stays collapsed, and+ // nodes outside it (content roots, contributed roots) stay open.+ // Keys of nodes that no longer exist are inert. Only a first open expands the roots.+ const persisted = mode === "project" ? readJson<string[]>(expandedKey(root)) : null;+ if (persisted) return new Set(persisted);+ return new Set(members ?? [root]);}function persistExpanded() {