Pārlūkot izejas kodu

Adds root path collapsing with compact hierarchy

main
Eric Amodio pirms 5 gadiem
vecāks
revīzija
1a66dd6a18
1 mainītis faili ar 16 papildinājumiem un 14 dzēšanām
  1. +16
    -14
      src/system/array.ts

+ 16
- 14
src/system/array.ts Parādīt failu

@ -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);

Notiek ielāde…
Atcelt
Saglabāt