Skip to content

Commit e192f31

Browse files
committed
Fixes #4521 ensures repoPath is included in id
1 parent 855fda4 commit e192f31

File tree

7 files changed

+13
-5
lines changed

7 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2323
- Fixes underlines showing on home branch actions ([#4703](https://github.com/gitkraken/vscode-gitlens/issues/4703))
2424
- Fixes _Inspect_ view not showing uncommitted files on the Inspect tab ([#4714](https://github.com/gitkraken/vscode-gitlens/issues/4714))
2525
- Fixes _Commit Graph_ losing row selection when graph updates ([#4544](https://github.com/gitkraken/vscode-gitlens/issues/4544))
26+
- Fixes "Element with id already registered" error on comparison w/ multiple repos ([#4521](https://github.com/gitkraken/vscode-gitlens/issues/4521))
2627

2728
## [17.6.2] - 2025-10-16
2829

src/views/nodes/abstract/repositoryFolderNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export abstract class RepositoryFolderNode<
2929
) {
3030
super('repo-folder', uri, view, parent);
3131

32-
this.updateContext({ repository: this.repo });
32+
this.updateContext({ repository: repo });
3333
this._uniqueId = getViewNodeId(this.type, this.context);
3434
}
3535

src/views/nodes/abstract/viewNode.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export interface AmbientContext {
127127
readonly reflog?: GitReflogRecord;
128128
readonly remote?: GitRemote;
129129
readonly repository?: Repository;
130+
readonly repoPath?: string;
130131
readonly root?: boolean;
131132
readonly searchId?: string;
132133
readonly storedComparisonId?: string;
@@ -150,8 +151,8 @@ export function getViewNodeId(type: string, context: AmbientContext): string {
150151
if (context.wsRepositoryDescriptor != null) {
151152
uniqueness += `/wsrepo/${context.wsRepositoryDescriptor.id}`;
152153
}
153-
if (context.repository != null) {
154-
uniqueness += `/repo/${context.repository.id}`;
154+
if (context.repository != null || context.repoPath != null) {
155+
uniqueness += `/repo/${context.repository?.id ?? context.repoPath}`;
155156
}
156157
if (context.worktree != null) {
157158
uniqueness += `/worktree/${context.worktree.uri.path}`;

src/views/nodes/compareResultsNode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export class CompareResultsNode extends SubscribeableViewNode<
4242

4343
this.updateContext({
4444
comparisonId: `${_ref.ref}+${_compareWith.ref}`,
45+
repoPath: repoPath,
4546
storedComparisonId: this.getStorageId(),
4647
});
4748
this._uniqueId = getViewNodeId(this.type, this.context);

src/views/nodes/repositoryNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class RepositoryNode extends SubscribeableViewNode<'repository', ViewsWit
4949
) {
5050
super('repository', uri, view, parent);
5151

52-
this.updateContext({ ...context, repository: this.repo });
52+
this.updateContext({ ...context, repository: repo });
5353
this._uniqueId = getViewNodeId(this.type, this.context);
5454

5555
this._status = this.repo.git.status.getStatus();

src/views/nodes/resultsCommitsNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class ResultsCommitsNodeBase<Type extends TreeViewNodeTypes, View extends
5656
super(type, GitUri.fromRepoPath(repoPath), view, parent);
5757

5858
if (_results.direction != null) {
59-
this.updateContext({ branchStatusUpstreamType: _results.direction });
59+
this.updateContext({ branchStatusUpstreamType: _results.direction, repoPath: repoPath });
6060
}
6161
this._uniqueId = getViewNodeId(this.type, this.context);
6262
this.limit = this.view.getNodeLastKnownLimit(this);

src/views/searchAndCompareView.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ export class SearchAndCompareViewNode extends ViewNode<'search-compare', SearchA
8181
const children = [...this.children];
8282
if (children.includes(results)) return;
8383

84+
const index = children.findIndex(c => c.id === results.id);
85+
if (index !== -1) {
86+
children.splice(index, 1);
87+
}
88+
8489
children.push(results);
8590
this.children = children;
8691

0 commit comments

Comments
 (0)