From 62446d381362ccc7021a6bf79eb48bb4fa6c491a Mon Sep 17 00:00:00 2001 From: Peter van Hardenberg Date: Thu, 22 Nov 2018 09:54:06 -0800 Subject: [PATCH] fix leaf nodes having expanders and titles for sub-docs --- src/treeview.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/treeview.ts b/src/treeview.ts index ffc1be0..3e2f3a9 100644 --- a/src/treeview.ts +++ b/src/treeview.ts @@ -48,19 +48,22 @@ export class HypermergeTreeDataProvider return this.hypermergeWrapper .openDocumentUri(resourceUri) .then((content: any) => { - let { docId, keyPath, label } = details; - if (!label) { - if (keyPath.length) { - label = keyPath.pop(); - } else if (content.title) { - label = `[${docId.slice(0, 5)}] ${content.title}`; - } else { - label = docId; - } + let { docId, keyPath } = details; + + let label; + if (keyPath.length) { + label = keyPath.pop(); + } else if (content.title) { + label = `[${docId.slice(0, 5)}] ${content.title}`; + } else { + label = docId; } // ideally we should determine if the node has / can have children - const collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + const collapsibleState = + content instanceof Array || content instanceof Object + ? vscode.TreeItemCollapsibleState.Collapsed + : vscode.TreeItemCollapsibleState.None; return { label, resourceUri, @@ -140,7 +143,7 @@ export class HypermergeTreeDataProvider content[child] ); if (docId) { - return "hypermerge://" + docId + "/?label=" + child + "-" + docId; + return "hypermerge://" + docId + "/"; } } // this builds a new child URL and ditches the label if it exists.