From 9718c98359aa48478665c88037aeee842eb7dcf0 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Tue, 1 Oct 2019 22:42:58 -0400 Subject: [PATCH] Fixes parenting of folder nodes --- src/views/nodes/folderNode.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/views/nodes/folderNode.ts b/src/views/nodes/folderNode.ts index ab159f6..dd098fa 100644 --- a/src/views/nodes/folderNode.ts +++ b/src/views/nodes/folderNode.ts @@ -43,14 +43,17 @@ export class FolderNode extends ViewNode { this.root.descendants, this.relativePath === undefined ); - if (nesting !== ViewFilesLayout.List) { + if (nesting === ViewFilesLayout.List) { + this.root.descendants.forEach(n => (n.relativePath = this.root.relativePath)); + children = this.root.descendants; + } else { children = []; for (const folder of this.root.children.values()) { if (folder.value === undefined) { children.push( new FolderNode( this.view, - this, + this.folderName ? this : this.parent!, this.repoPath, folder.name, folder, @@ -61,12 +64,11 @@ export class FolderNode extends ViewNode { continue; } + // Make sure to set the parent + (folder.value as any).parent = this.folderName ? this : this.parent!; folder.value.relativePath = this.root.relativePath; children.push(folder.value); } - } else { - this.root.descendants.forEach(n => (n.relativePath = this.root.relativePath)); - children = this.root.descendants; } children.sort((a, b) => {