Skip to content

Commit 1255803

Browse files
committed
Fixes active repo tracking in explorer
Fixes status node updates in explorer
1 parent 7a61eb1 commit 1255803

File tree

5 files changed

+34
-6
lines changed

5 files changed

+34
-6
lines changed

src/views/activeRepositoryNode.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export class ActiveRepositoryNode extends ExplorerNode {
3333
}
3434
}
3535

36+
get id(): string {
37+
return 'gitlens:repository:active';
38+
}
39+
3640
private async onActiveEditorChanged(editor: TextEditor | undefined) {
3741
if (editor !== undefined && !isTextEditor(editor)) return;
3842

@@ -86,8 +90,10 @@ export class ActiveRepositoryNode extends ExplorerNode {
8690
}
8791

8892
getTreeItem(): TreeItem {
89-
return this._repositoryNode !== undefined
93+
const item = this._repositoryNode !== undefined
9094
? this._repositoryNode.getTreeItem()
9195
: new TreeItem('No active repository', TreeItemCollapsibleState.None);
96+
item.id = this.id;
97+
return item;
9298
}
9399
}

src/views/repositoryNode.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ export class RepositoryNode extends ExplorerNode {
2323
super(uri);
2424
}
2525

26+
get id(): string {
27+
return `gitlens:repository(${this.repo.path})${this.active ? ':active' : ''}`;
28+
}
29+
2630
async getChildren(): Promise<ExplorerNode[]> {
2731
this.resetChildren();
2832
this.updateSubscription();
@@ -45,6 +49,7 @@ export class RepositoryNode extends ExplorerNode {
4549
: `${this.repo.formattedName || this.uri.repoPath}`;
4650

4751
const item = new TreeItem(label, this.active ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.Collapsed);
52+
item.id = this.id;
4853
item.contextValue = ResourceType.Repository;
4954
return item;
5055
}

src/views/statusFilesNode.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@ export class StatusFilesNode extends ExplorerNode {
1818
constructor(
1919
public readonly status: GitStatus,
2020
public readonly range: string | undefined,
21-
private readonly explorer: GitExplorer
21+
private readonly explorer: GitExplorer,
22+
private readonly active: boolean = false
2223
) {
2324
super(GitUri.fromRepoPath(status.repoPath));
2425
this.repoPath = status.repoPath;
2526
}
2627

28+
get id(): string {
29+
return `gitlens:repository(${this.status.repoPath})${this.active ? ':active' : ''}:status:files`;
30+
}
31+
2732
async getChildren(): Promise<ExplorerNode[]> {
2833
let statuses: IGitStatusFileWithCommit[] = [];
2934

@@ -119,6 +124,7 @@ export class StatusFilesNode extends ExplorerNode {
119124

120125
const label = `${files} file${files > 1 ? 's' : ''} changed`; // ${this.status.upstream === undefined ? '' : ` (ahead of ${this.status.upstream})`}`;
121126
const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
127+
item.id = this.id;
122128
item.contextValue = ResourceType.StatusFiles;
123129
item.iconPath = {
124130
dark: Container.context.asAbsolutePath(`images/dark/icon-diff.svg`),

src/views/statusNode.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export class StatusNode extends ExplorerNode {
1717
super(uri);
1818
}
1919

20+
get id(): string {
21+
return `gitlens:repository(${this.repo.path})${this.active ? ':active' : ''}:status`;
22+
}
23+
2024
async getChildren(): Promise<ExplorerNode[]> {
2125
this.resetChildren();
2226

@@ -26,18 +30,18 @@ export class StatusNode extends ExplorerNode {
2630
this.children = [];
2731

2832
if (status.state.behind) {
29-
this.children.push(new StatusUpstreamNode(status, 'behind', this.explorer));
33+
this.children.push(new StatusUpstreamNode(status, 'behind', this.explorer, this.active));
3034
}
3135

3236
if (status.state.ahead) {
33-
this.children.push(new StatusUpstreamNode(status, 'ahead', this.explorer));
37+
this.children.push(new StatusUpstreamNode(status, 'ahead', this.explorer, this.active));
3438
}
3539

3640
if (status.state.ahead || (status.files.length !== 0 && this.includeWorkingTree)) {
3741
const range = status.upstream
3842
? `${status.upstream}..${status.branch}`
3943
: undefined;
40-
this.children.push(new StatusFilesNode(status, range, this.explorer));
44+
this.children.push(new StatusFilesNode(status, range, this.explorer, this.active));
4145
}
4246

4347
return this.children;
@@ -99,6 +103,7 @@ export class StatusNode extends ExplorerNode {
99103
}
100104

101105
const item = new TreeItem(label, state);
106+
item.id = this.id;
102107
item.contextValue = ResourceType.Status;
103108

104109
item.iconPath = {

src/views/statusUpstreamNode.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ export class StatusUpstreamNode extends ExplorerNode {
1111
constructor(
1212
public readonly status: GitStatus,
1313
public readonly direction: 'ahead' | 'behind',
14-
private readonly explorer: Explorer
14+
private readonly explorer: Explorer,
15+
private readonly active: boolean = false
1516
) {
1617
super(GitUri.fromRepoPath(status.repoPath));
1718
}
1819

20+
get id(): string {
21+
return `gitlens:repository(${this.status.repoPath})${this.active ? ':active' : ''}:status:upstream`;
22+
}
23+
1924
async getChildren(): Promise<ExplorerNode[]> {
2025
const range = this.direction === 'ahead'
2126
? `${this.status.upstream}..${this.status.branch}`
@@ -45,6 +50,7 @@ export class StatusUpstreamNode extends ExplorerNode {
4550
: `${this.status.state.behind} commit${this.status.state.behind > 1 ? 's' : ''} (behind ${this.status.upstream})`;
4651

4752
const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
53+
item.id = this.id;
4854
item.contextValue = ResourceType.StatusUpstream;
4955

5056
item.iconPath = {

0 commit comments

Comments
 (0)