Skip to content

Commit 12eba66

Browse files
committed
Fixes #2738 not unique enough ids
1 parent 6779aa2 commit 12eba66

File tree

7 files changed

+17
-21
lines changed

7 files changed

+17
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
7575

7676
### Fixed
7777

78+
- Fixes [#2738](https://github.com/gitkraken/vscode-gitlens/issues/2738) - Element with id ... is already registered
7879
- Fixes [#2728](https://github.com/gitkraken/vscode-gitlens/issues/2728) - Submodule commit graph will not open in the panel layout
7980
- Fixes [#2734](https://github.com/gitkraken/vscode-gitlens/issues/2734) - 🐛 File History: Browse ... not working
8081
- Fixes [#2671](https://github.com/gitkraken/vscode-gitlens/issues/2671) - Incorrect locale information provided GitLens

src/views/nodes/autolinkedItemsNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class AutolinkedItemsNode extends ViewNode<ViewsWithCommits> {
2929

3030
this._instanceId = instanceId++;
3131
this.updateContext({ autolinksId: String(this._instanceId) });
32-
this._uniqueId = getViewNodeId(`autolinks`, this.context);
32+
this._uniqueId = getViewNodeId('autolinks', this.context);
3333
}
3434

3535
override get id(): string {

src/views/nodes/compareBranchNode.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export class CompareBranchNode extends ViewNode<ViewsWithBranches | WorktreesVie
8989
},
9090
},
9191
{
92-
id: 'behind',
9392
description: pluralize('commit', aheadBehindCounts?.behind ?? 0),
9493
expand: false,
9594
},
@@ -112,7 +111,6 @@ export class CompareBranchNode extends ViewNode<ViewsWithBranches | WorktreesVie
112111
},
113112
},
114113
{
115-
id: 'ahead',
116114
description: pluralize('commit', aheadBehindCounts?.ahead ?? 0),
117115
expand: false,
118116
},
@@ -125,9 +123,7 @@ export class CompareBranchNode extends ViewNode<ViewsWithBranches | WorktreesVie
125123
this.compareWithWorkingTree ? '' : this.branch.ref,
126124
this.getFilesQuery.bind(this),
127125
undefined,
128-
{
129-
expand: false,
130-
},
126+
{ expand: false },
131127
),
132128
];
133129
}

src/views/nodes/compareResultsNode.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ export class CompareResultsNode extends ViewNode<SearchAndCompareView> {
101101
},
102102
},
103103
{
104-
id: 'behind',
105104
description: pluralize('commit', aheadBehindCounts?.behind ?? 0),
106105
expand: false,
107106
},
@@ -122,7 +121,6 @@ export class CompareResultsNode extends ViewNode<SearchAndCompareView> {
122121
},
123122
},
124123
{
125-
id: 'ahead',
126124
description: pluralize('commit', aheadBehindCounts?.ahead ?? 0),
127125
expand: false,
128126
},
@@ -135,9 +133,7 @@ export class CompareResultsNode extends ViewNode<SearchAndCompareView> {
135133
this._ref.ref,
136134
this.getFilesQuery.bind(this),
137135
undefined,
138-
{
139-
expand: false,
140-
},
136+
{ expand: false },
141137
),
142138
];
143139
}

src/views/nodes/resultsCommitsNode.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,15 @@ export class ResultsCommitsNode<View extends ViewsWithCommits = ViewsWithCommits
4747
query: () => Promise<FilesQueryResults>;
4848
};
4949
},
50-
private readonly _options: {
51-
id?: string;
52-
description?: string;
53-
expand?: boolean;
54-
} = undefined!,
50+
private readonly _options: { description?: string; expand?: boolean } = undefined!,
5551
splatted?: boolean,
5652
) {
5753
super(GitUri.fromRepoPath(repoPath), view, parent);
5854

59-
this._uniqueId = getViewNodeId(`results-commits${_options?.id ? `+${_options.id}` : ''}`, this.context);
55+
if (_results.direction != null) {
56+
this.updateContext({ branchStatusUpstreamType: _results.direction });
57+
}
58+
this._uniqueId = getViewNodeId('results-commits', this.context);
6059
this.limit = this.view.getNodeLastKnownLimit(this);
6160

6261
this._options = { expand: true, ..._options };

src/views/nodes/resultsFilesNode.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ export class ResultsFilesNode extends ViewNode<ViewsWithCommits> {
4444
) {
4545
super(GitUri.fromRepoPath(repoPath), view, parent);
4646

47-
this._uniqueId = getViewNodeId(`results-files${direction ? `+${direction}` : ''}`, this.context);
47+
if (this.direction != null) {
48+
this.updateContext({ branchStatusUpstreamType: this.direction });
49+
}
50+
this._uniqueId = getViewNodeId('results-files', this.context);
4851
this._options = { expand: true, ..._options };
4952
}
5053

src/views/nodes/viewNode.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ export function getViewNodeId(type: string, context: AmbientContext): string {
144144
uniqueness += `/branch/${context.branch.id}`;
145145
}
146146
if (context.branchStatus != null) {
147-
uniqueness += `/status/${context.branchStatus.upstream ?? '-'}${
148-
context.branchStatusUpstreamType ? `/${context.branchStatusUpstreamType}` : ''
149-
}`;
147+
uniqueness += `/status/${context.branchStatus.upstream ?? '-'}`;
148+
}
149+
if (context.branchStatusUpstreamType != null) {
150+
uniqueness += `/status-direction/${context.branchStatusUpstreamType}`;
150151
}
151152
if (context.reflog != null) {
152153
uniqueness += `/reflog/${context.reflog.sha}+${context.reflog.selector}+${context.reflog.command}+${

0 commit comments

Comments
 (0)