From e77be8bf57c4fbb2a0bc22bafb045af45925a30d Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 27 Apr 2019 02:35:13 -0400 Subject: [PATCH] Fixes id collisions with branches/remotes/tags --- src/views/nodes/branchOrTagFolderNode.ts | 6 +++++- src/views/nodes/branchesNode.ts | 11 ++++++++++- src/views/nodes/remoteNode.ts | 3 ++- src/views/nodes/tagsNode.ts | 11 ++++++++++- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/views/nodes/branchOrTagFolderNode.ts b/src/views/nodes/branchOrTagFolderNode.ts index c15b947..be48352 100644 --- a/src/views/nodes/branchOrTagFolderNode.ts +++ b/src/views/nodes/branchOrTagFolderNode.ts @@ -16,13 +16,16 @@ export class BranchOrTagFolderNode extends ViewNode { public readonly folderName: string, public readonly relativePath: string | undefined, public readonly root: Arrays.HierarchicalItem, + private readonly _key?: string, private readonly _expanded: boolean = false ) { super(GitUri.fromRepoPath(repoPath), view, parent); } get id(): string { - return `${this._instanceId}:gitlens:repository(${this.repoPath}):${this.type}-folder(${this.relativePath})`; + return `${this._instanceId}:gitlens:repository(${this.repoPath})${ + this._key === undefined ? '' : `:${this._key}` + }:${this.type}-folder(${this.relativePath})`; } getChildren(): ViewNode[] { @@ -45,6 +48,7 @@ export class BranchOrTagFolderNode extends ViewNode { folder.name, folder.relativePath, folder, + this._key, expanded ) ); diff --git a/src/views/nodes/branchesNode.ts b/src/views/nodes/branchesNode.ts index 24739a3..55455f2 100644 --- a/src/views/nodes/branchesNode.ts +++ b/src/views/nodes/branchesNode.ts @@ -46,7 +46,16 @@ export class BranchesNode extends ViewNode { this.view.config.files.compact ); - const root = new BranchOrTagFolderNode(this.view, this, 'branch', this.repo.path, '', undefined, hierarchy); + const root = new BranchOrTagFolderNode( + this.view, + this, + 'branch', + this.repo.path, + '', + undefined, + hierarchy, + 'branches' + ); this._children = await root.getChildren(); } return this._children; diff --git a/src/views/nodes/remoteNode.ts b/src/views/nodes/remoteNode.ts index beae153..bc955af 100644 --- a/src/views/nodes/remoteNode.ts +++ b/src/views/nodes/remoteNode.ts @@ -61,7 +61,8 @@ export class RemoteNode extends ViewNode { this.repo.path, '', undefined, - hierarchy + hierarchy, + `remote(${this.remote.name}` ); const children = (await root.getChildren()) as (BranchOrTagFolderNode | BranchNode)[]; diff --git a/src/views/nodes/tagsNode.ts b/src/views/nodes/tagsNode.ts index 80405d0..0c3204b 100644 --- a/src/views/nodes/tagsNode.ts +++ b/src/views/nodes/tagsNode.ts @@ -34,7 +34,16 @@ export class TagsNode extends ViewNode { this.view.config.files.compact ); - const root = new BranchOrTagFolderNode(this.view, this, 'tag', this.repo.path, '', undefined, hierarchy); + const root = new BranchOrTagFolderNode( + this.view, + this, + 'tag', + this.repo.path, + '', + undefined, + hierarchy, + 'tags' + ); const children = (await root.getChildren()) as (BranchOrTagFolderNode | TagNode)[]; return children; }