Skip to content

Commit 5e668aa

Browse files
committed
Adds the view name into the node uniqueness
1 parent 99ed434 commit 5e668aa

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/views/nodes/abstract/viewNode.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { CancellationToken, Command, Disposable, Event, TreeItem } from 'vscode';
2-
import type { TreeViewNodeTypes } from '../../../constants.views';
2+
import type { TreeViewNodeTypes, TreeViewTypes } from '../../../constants.views';
33
import type { GitUri } from '../../../git/gitUri';
44
import type { GitBranch } from '../../../git/models/branch';
55
import type { GitCommit } from '../../../git/models/commit';
@@ -131,6 +131,7 @@ export interface AmbientContext {
131131
readonly searchId?: string;
132132
readonly storedComparisonId?: string;
133133
readonly tag?: GitTag;
134+
readonly viewType?: TreeViewTypes;
134135
readonly workspace?: CloudWorkspace | LocalWorkspace;
135136
readonly wsRepositoryDescriptor?: CloudWorkspaceRepositoryDescriptor | LocalWorkspaceRepositoryDescriptor;
136137
readonly worktree?: GitWorktree;
@@ -213,7 +214,7 @@ export function getViewNodeId(type: string, context: AmbientContext): string {
213214
uniqueness += `/draft/${context.draft.id}`;
214215
}
215216

216-
return `gitlens://viewnode/${type}${uniqueness}`;
217+
return `gitlens://${context.viewType ?? 'view'}/${type}${uniqueness}`;
217218
}
218219

219220
export type ClipboardType = 'text' | 'markdown';
@@ -247,6 +248,8 @@ export abstract class ViewNode<
247248
public readonly view: TView,
248249
protected parent?: ViewNode | undefined,
249250
) {
251+
this.updateContext({ viewType: view.type });
252+
250253
// NOTE: @eamodio uncomment to track node leaks
251254
// queueMicrotask(() => this.view.registerNode(this));
252255
this._uri = uri;
@@ -279,7 +282,7 @@ export abstract class ViewNode<
279282

280283
private _context: AmbientContext | undefined;
281284
protected get context(): AmbientContext {
282-
return this._context ?? this.parent?.context ?? {};
285+
return this._context ?? this.parent?.context ?? { viewType: this.view.type };
283286
}
284287

285288
protected updateContext(context: AmbientContext, reset: boolean = false): void {

src/views/viewBase.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,12 @@ export abstract class ViewBase<
277277
if (typeof item.tooltip === 'string') {
278278
item.tooltip = `${item.tooltip}\n\n---\ncontext: ${
279279
item.contextValue
280-
}\nnode: ${node.toString()}\nparent: ${parent?.toString()}`;
280+
}\nnode: ${node.toString()}\nparent: ${parent?.toString()}\nid: ${node.id}`;
281281
} else {
282282
item.tooltip.appendMarkdown(
283283
`\n\n---\n\ncontext: \`${
284284
item.contextValue
285-
}\`\\\nnode: \`${node.toString()}\` \\\nparent: \`${parent?.toString()}\``,
285+
}\`\\\nnode: \`${node.toString()}\` \\\nparent: \`${parent?.toString()}\` \\\nid: \`${node.id}\``,
286286
);
287287
}
288288
}

0 commit comments

Comments
 (0)