|
1 | 1 | import type { CancellationToken, Command, Disposable, Event, TreeItem } from 'vscode';
|
2 |
| -import type { TreeViewNodeTypes } from '../../../constants.views'; |
| 2 | +import type { TreeViewNodeTypes, TreeViewTypes } from '../../../constants.views'; |
3 | 3 | import type { GitUri } from '../../../git/gitUri';
|
4 | 4 | import type { GitBranch } from '../../../git/models/branch';
|
5 | 5 | import type { GitCommit } from '../../../git/models/commit';
|
@@ -131,6 +131,7 @@ export interface AmbientContext {
|
131 | 131 | readonly searchId?: string;
|
132 | 132 | readonly storedComparisonId?: string;
|
133 | 133 | readonly tag?: GitTag;
|
| 134 | + readonly viewType?: TreeViewTypes; |
134 | 135 | readonly workspace?: CloudWorkspace | LocalWorkspace;
|
135 | 136 | readonly wsRepositoryDescriptor?: CloudWorkspaceRepositoryDescriptor | LocalWorkspaceRepositoryDescriptor;
|
136 | 137 | readonly worktree?: GitWorktree;
|
@@ -213,7 +214,7 @@ export function getViewNodeId(type: string, context: AmbientContext): string {
|
213 | 214 | uniqueness += `/draft/${context.draft.id}`;
|
214 | 215 | }
|
215 | 216 |
|
216 |
| - return `gitlens://viewnode/${type}${uniqueness}`; |
| 217 | + return `gitlens://${context.viewType ?? 'view'}/${type}${uniqueness}`; |
217 | 218 | }
|
218 | 219 |
|
219 | 220 | export type ClipboardType = 'text' | 'markdown';
|
@@ -247,6 +248,8 @@ export abstract class ViewNode<
|
247 | 248 | public readonly view: TView,
|
248 | 249 | protected parent?: ViewNode | undefined,
|
249 | 250 | ) {
|
| 251 | + this.updateContext({ viewType: view.type }); |
| 252 | + |
250 | 253 | // NOTE: @eamodio uncomment to track node leaks
|
251 | 254 | // queueMicrotask(() => this.view.registerNode(this));
|
252 | 255 | this._uri = uri;
|
@@ -279,7 +282,7 @@ export abstract class ViewNode<
|
279 | 282 |
|
280 | 283 | private _context: AmbientContext | undefined;
|
281 | 284 | protected get context(): AmbientContext {
|
282 |
| - return this._context ?? this.parent?.context ?? {}; |
| 285 | + return this._context ?? this.parent?.context ?? { viewType: this.view.type }; |
283 | 286 | }
|
284 | 287 |
|
285 | 288 | protected updateContext(context: AmbientContext, reset: boolean = false): void {
|
|
0 commit comments