refac
This commit is contained in:
1 parent
c93c6d6fc4
commit
52c5e3b20d
1 file changed
+13
-1
@@ -1,6 +1,7 @@
|
|||||||
<script context="module">
|
<script context="module">
|
||||||
// Persists across mount/unmount cycles (module-level, not per-instance)
|
// Persists across mount/unmount cycles (module-level, not per-instance)
|
||||||
let savedPath = '/';
|
let savedPath = '/';
|
||||||
|
let savedFileRoot = null;
|
||||||
const treeExpandedCache = new Map<string, string[]>();
|
const treeExpandedCache = new Map<string, string[]>();
|
||||||
const treeContentsCache = new Map<string, [string, any[]][]>();
|
const treeContentsCache = new Map<string, [string, any[]][]>();
|
||||||
</script>
|
</script>
|
||||||
@@ -92,7 +93,7 @@
|
|||||||
|
|
||||||
// ── Directory state ──────────────────────────────────────────────────
|
// ── Directory state ──────────────────────────────────────────────────
|
||||||
let currentPath = savedPath;
|
let currentPath = savedPath;
|
||||||
let fileRoot: TerminalFileRoot | null = null;
|
let fileRoot: TerminalFileRoot | null = savedFileRoot;
|
||||||
let entries: FileEntry[] = [];
|
let entries: FileEntry[] = [];
|
||||||
let currentWritable = true;
|
let currentWritable = true;
|
||||||
let loading = false;
|
let loading = false;
|
||||||
@@ -463,6 +464,7 @@
|
|||||||
label: root.label || labelFromPath(root.path)
|
label: root.label || labelFromPath(root.path)
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
|
savedFileRoot = fileRoot;
|
||||||
if ((fileRoot?.path ?? null) !== previousRoot) resetTreeState();
|
if ((fileRoot?.path ?? null) !== previousRoot) resetTreeState();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -485,6 +487,16 @@
|
|||||||
|
|
||||||
if (rootPath && rootPath !== '/') return cwd?.root;
|
if (rootPath && rootPath !== '/') return cwd?.root;
|
||||||
|
|
||||||
|
const knownRoot = fileRoot ?? savedFileRoot;
|
||||||
|
if (
|
||||||
|
knownRoot?.path &&
|
||||||
|
hintPath &&
|
||||||
|
hintPath !== '/' &&
|
||||||
|
(hintPath === knownRoot.path || hintPath.startsWith(knownRoot.path))
|
||||||
|
) {
|
||||||
|
return knownRoot;
|
||||||
|
}
|
||||||
|
|
||||||
const pathForHome = hintPath && hintPath !== '/' ? hintPath : cwdPath;
|
const pathForHome = hintPath && hintPath !== '/' ? hintPath : cwdPath;
|
||||||
if (
|
if (
|
||||||
homePath &&
|
homePath &&
|
||||||
|
|||||||
Reference in new issue
Block a user