diff --git a/src/views/activeRepositoryNode.ts b/src/views/activeRepositoryNode.ts index a066d60..46fb1ef 100644 --- a/src/views/activeRepositoryNode.ts +++ b/src/views/activeRepositoryNode.ts @@ -33,6 +33,10 @@ export class ActiveRepositoryNode extends ExplorerNode { } } + get id(): string { + return 'gitlens:repository:active'; + } + private async onActiveEditorChanged(editor: TextEditor | undefined) { if (editor !== undefined && !isTextEditor(editor)) return; @@ -86,8 +90,10 @@ export class ActiveRepositoryNode extends ExplorerNode { } getTreeItem(): TreeItem { - return this._repositoryNode !== undefined + const item = this._repositoryNode !== undefined ? this._repositoryNode.getTreeItem() : new TreeItem('No active repository', TreeItemCollapsibleState.None); + item.id = this.id; + return item; } } diff --git a/src/views/repositoryNode.ts b/src/views/repositoryNode.ts index 2506739..3de5c9a 100644 --- a/src/views/repositoryNode.ts +++ b/src/views/repositoryNode.ts @@ -23,6 +23,10 @@ export class RepositoryNode extends ExplorerNode { super(uri); } + get id(): string { + return `gitlens:repository(${this.repo.path})${this.active ? ':active' : ''}`; + } + async getChildren(): Promise { this.resetChildren(); this.updateSubscription(); @@ -45,6 +49,7 @@ export class RepositoryNode extends ExplorerNode { : `${this.repo.formattedName || this.uri.repoPath}`; const item = new TreeItem(label, this.active ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.Collapsed); + item.id = this.id; item.contextValue = ResourceType.Repository; return item; } diff --git a/src/views/statusFilesNode.ts b/src/views/statusFilesNode.ts index 6223b38..9dfe5e2 100644 --- a/src/views/statusFilesNode.ts +++ b/src/views/statusFilesNode.ts @@ -18,12 +18,17 @@ export class StatusFilesNode extends ExplorerNode { constructor( public readonly status: GitStatus, public readonly range: string | undefined, - private readonly explorer: GitExplorer + private readonly explorer: GitExplorer, + private readonly active: boolean = false ) { super(GitUri.fromRepoPath(status.repoPath)); this.repoPath = status.repoPath; } + get id(): string { + return `gitlens:repository(${this.status.repoPath})${this.active ? ':active' : ''}:status:files`; + } + async getChildren(): Promise { let statuses: IGitStatusFileWithCommit[] = []; @@ -119,6 +124,7 @@ export class StatusFilesNode extends ExplorerNode { const label = `${files} file${files > 1 ? 's' : ''} changed`; // ${this.status.upstream === undefined ? '' : ` (ahead of ${this.status.upstream})`}`; const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed); + item.id = this.id; item.contextValue = ResourceType.StatusFiles; item.iconPath = { dark: Container.context.asAbsolutePath(`images/dark/icon-diff.svg`), diff --git a/src/views/statusNode.ts b/src/views/statusNode.ts index e95cc6e..d6759e6 100644 --- a/src/views/statusNode.ts +++ b/src/views/statusNode.ts @@ -17,6 +17,10 @@ export class StatusNode extends ExplorerNode { super(uri); } + get id(): string { + return `gitlens:repository(${this.repo.path})${this.active ? ':active' : ''}:status`; + } + async getChildren(): Promise { this.resetChildren(); @@ -26,18 +30,18 @@ export class StatusNode extends ExplorerNode { this.children = []; if (status.state.behind) { - this.children.push(new StatusUpstreamNode(status, 'behind', this.explorer)); + this.children.push(new StatusUpstreamNode(status, 'behind', this.explorer, this.active)); } if (status.state.ahead) { - this.children.push(new StatusUpstreamNode(status, 'ahead', this.explorer)); + this.children.push(new StatusUpstreamNode(status, 'ahead', this.explorer, this.active)); } if (status.state.ahead || (status.files.length !== 0 && this.includeWorkingTree)) { const range = status.upstream ? `${status.upstream}..${status.branch}` : undefined; - this.children.push(new StatusFilesNode(status, range, this.explorer)); + this.children.push(new StatusFilesNode(status, range, this.explorer, this.active)); } return this.children; @@ -99,6 +103,7 @@ export class StatusNode extends ExplorerNode { } const item = new TreeItem(label, state); + item.id = this.id; item.contextValue = ResourceType.Status; item.iconPath = { diff --git a/src/views/statusUpstreamNode.ts b/src/views/statusUpstreamNode.ts index d620329..1cd6924 100644 --- a/src/views/statusUpstreamNode.ts +++ b/src/views/statusUpstreamNode.ts @@ -11,11 +11,16 @@ export class StatusUpstreamNode extends ExplorerNode { constructor( public readonly status: GitStatus, public readonly direction: 'ahead' | 'behind', - private readonly explorer: Explorer + private readonly explorer: Explorer, + private readonly active: boolean = false ) { super(GitUri.fromRepoPath(status.repoPath)); } + get id(): string { + return `gitlens:repository(${this.status.repoPath})${this.active ? ':active' : ''}:status:upstream`; + } + async getChildren(): Promise { const range = this.direction === 'ahead' ? `${this.status.upstream}..${this.status.branch}` @@ -45,6 +50,7 @@ export class StatusUpstreamNode extends ExplorerNode { : `${this.status.state.behind} commit${this.status.state.behind > 1 ? 's' : ''} (behind ${this.status.upstream})`; const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed); + item.id = this.id; item.contextValue = ResourceType.StatusUpstream; item.iconPath = {