浏览代码

Adds root path collapsing with compact hierarchy

main
Eric Amodio 5 年前
父节点
当前提交
1a66dd6a18
共有 1 个文件被更改,包括 16 次插入14 次删除
  1. +16
    -14
      src/system/array.ts

+ 16
- 14
src/system/array.ts 查看文件

@ -83,7 +83,7 @@ export namespace Arrays {
relativePath: string;
value?: T;
// parent?: HierarchicalItem<T>;
parent?: HierarchicalItem<T>;
children: Map<string, HierarchicalItem<T>> | undefined;
descendants: T[] | undefined;
}
@ -117,7 +117,7 @@ export namespace Arrays {
f = {
name: folderName,
relativePath: relativePath,
// parent: folder,
parent: folder,
children: undefined,
descendants: undefined
};
@ -149,18 +149,20 @@ export namespace Arrays {
const children = [...root.children.values()];
// // Attempts less nesting but duplicate roots
// if (!isRoot && children.every(c => c.value === undefined)) {
// const parentSiblings = root.parent!.children!;
// if (parentSiblings[root.name] !== undefined) {
// delete parentSiblings[root.name];
// for (const child of children) {
// child.name = joinPath(root.name, child.name);
// parentSiblings[child.name] = child;
// }
// }
// }
// Less nesting but duplicate roots
if (!isRoot && children.every(c => c.value === undefined)) {
const siblings = root.parent && root.parent.children;
if (siblings !== undefined) {
if (siblings.get(root.name) !== undefined) {
siblings.delete(root.name);
for (const child of children) {
child.name = joinPath(root.name, child.name);
siblings.set(child.name, child);
}
}
}
}
for (const child of children) {
compactHierarchy(child, joinPath, false);

正在加载...
取消
保存