Skip to content

Commit 578f103

Browse files
committed
Fixes state getting lost w/ search/compare nodes
Removes ViewNode.instanceId Better persists search/compare tree ids
1 parent 6d7f4bd commit 578f103

25 files changed

+68
-79
lines changed

src/views/nodes/branchNode.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ export class BranchNode extends ViewRefNode<RepositoriesView> implements Pageabl
3030
}
3131

3232
get id(): string {
33-
return `${this._instanceId}:gitlens:repository(${this.branch.repoPath})${this._root ? ':root:' : ''}:branch(${
34-
this.branch.name
35-
})${this.branch.current ? '+current:' : ''}${this.branch.remote ? '+remote' : ''}${
36-
this.branch.starred ? '+starred:' : ''
37-
}`;
33+
return `gitlens:repository(${this.branch.repoPath})${this._root ? ':root' : ''}:branch(${this.branch.name})${
34+
this.branch.current ? '+current' : ''
35+
}${this.branch.remote ? '+remote' : ''}${this.branch.starred ? '+starred' : ''}`;
3836
}
3937

4038
get current(): boolean {
@@ -206,7 +204,7 @@ export class BranchNode extends ViewRefNode<RepositoriesView> implements Pageabl
206204

207205
@gate()
208206
@debug()
209-
refresh() {
207+
refresh(reset: boolean = false) {
210208
this._children = undefined;
211209
}
212210
}

src/views/nodes/branchOrTagFolderNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class BranchOrTagFolderNode extends ViewNode {
2323
}
2424

2525
get id(): string {
26-
return `${this._instanceId}:gitlens:repository(${this.repoPath})${
26+
return `gitlens:repository(${this.repoPath})${
2727
this._key === undefined ? '' : `:${this._key}`
2828
}:${this.type}-folder(${this.relativePath})`;
2929
}

src/views/nodes/branchTrackingStatusNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class BranchTrackingStatusNode extends ViewNode<ViewWithFiles> implements
3232
}
3333

3434
get id(): string {
35-
return `${this._instanceId}:gitlens:repository(${this.status.repoPath}):${this._root ? 'root:' : ''}branch(${
35+
return `gitlens:repository(${this.status.repoPath}):${this._root ? 'root:' : ''}branch(${
3636
this.status.ref
3737
}):status:upstream:(${this.status.upstream}):${this.direction}`;
3838
}

src/views/nodes/branchesNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class BranchesNode extends ViewNode<RepositoriesView> {
1717
}
1818

1919
get id(): string {
20-
return `${this._instanceId}:gitlens:repository(${this.repo.path}):branches`;
20+
return `gitlens:repository(${this.repo.path}):branches`;
2121
}
2222

2323
async getChildren(): Promise<ViewNode[]> {

src/views/nodes/compareBranchNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class CompareBranchNode extends ViewNode<RepositoriesView> {
2222
}
2323

2424
get id(): string {
25-
return `${this._instanceId}:gitlens:repository(${this.branch.repoPath}):branch(${this.branch.name}):compareWith`;
25+
return `gitlens:repository(${this.branch.repoPath}):branch(${this.branch.name}):compareWith`;
2626
}
2727

2828
getChildren(): ViewNode[] {

src/views/nodes/compareNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class CompareNode extends ViewNode<CompareView> {
119119

120120
const promises: Promise<any>[] = [
121121
...Iterables.filterMap(this._children, c => {
122-
const result = c.refresh();
122+
const result = c.refresh === undefined ? false : c.refresh();
123123
return Functions.isPromise<boolean | void>(result) ? result : undefined;
124124
})
125125
];

src/views/nodes/compareResultsNode.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ import { CommitsQueryResults, ResultsCommitsNode } from './resultsCommitsNode';
99
import { ResultsFilesNode } from './resultsFilesNode';
1010
import { ResourceType, SubscribeableViewNode, ViewNode } from './viewNode';
1111

12+
let instanceId = 0;
13+
1214
export class CompareResultsNode extends SubscribeableViewNode<CompareView> {
1315
private _children: ViewNode[] | undefined;
16+
private _instanceId: number;
1417

1518
constructor(
1619
view: CompareView,
@@ -20,6 +23,11 @@ export class CompareResultsNode extends SubscribeableViewNode<CompareView> {
2023
private _pinned: boolean = false
2124
) {
2225
super(GitUri.fromRepoPath(repoPath), view);
26+
this._instanceId = instanceId++;
27+
}
28+
29+
get id(): string {
30+
return `gitlens:repository(${this.repoPath}):compare(${this._ref1.ref}:${this._ref2.ref})|${this._instanceId}`;
2331
}
2432

2533
get label() {

src/views/nodes/contributorNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class ContributorNode extends ViewNode<RepositoriesView> implements Pagea
1919
}
2020

2121
get id(): string {
22-
return `${this._instanceId}:gitlens:repository(${this.contributor.repoPath}):contributor(${this.contributor.name}|${this.contributor.email}}`;
22+
return `gitlens:repository(${this.contributor.repoPath}):contributor(${this.contributor.name}|${this.contributor.email}}`;
2323
}
2424

2525
async getChildren(): Promise<ViewNode[]> {

src/views/nodes/contributorsNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class ContributorsNode extends ViewNode<RepositoriesView> {
1313
}
1414

1515
get id(): string {
16-
return `${this._instanceId}:gitlens:repository(${this.repo.path}):contributors`;
16+
return `gitlens:repository(${this.repo.path}):contributors`;
1717
}
1818

1919
async getChildren(): Promise<ViewNode[]> {

src/views/nodes/reflogNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class ReflogNode extends ViewNode<RepositoriesView> implements PageableVi
1919
}
2020

2121
get id(): string {
22-
return `${this._instanceId}:gitlens:repository(${this.repo.path}):reflog`;
22+
return `gitlens:repository(${this.repo.path}):reflog`;
2323
}
2424

2525
async getChildren(): Promise<ViewNode[]> {

0 commit comments

Comments
 (0)