diff --git a/src/views/nodes/compareBranchNode.ts b/src/views/nodes/compareBranchNode.ts index 3b56244..38eceeb 100644 --- a/src/views/nodes/compareBranchNode.ts +++ b/src/views/nodes/compareBranchNode.ts @@ -32,18 +32,7 @@ export class CompareBranchNode extends ViewNode(WorkspaceState.BranchComparisons); - const compareWith = comparisons?.[branch.id]; - if (compareWith !== undefined && typeof compareWith === 'string') { - this._compareWith = { - ref: compareWith, - notation: undefined, - // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - type: this.view.config.showBranchComparison || ViewShowBranchComparison.Working, - }; - } else { - this._compareWith = compareWith; - } + this.loadCompareWith(); } get ahead(): { readonly ref1: string; readonly ref2: string } { @@ -133,7 +122,7 @@ export class CompareBranchNode extends ViewNode`; @@ -182,11 +171,12 @@ export class CompareBranchNode extends ViewNode) { - if (this._compareWith !== undefined) { + if (this._compareWith != null) { await this.updateCompareWith({ ...this._compareWith, type: comparisonType }); } @@ -218,7 +208,7 @@ export class CompareBranchNode extends ViewNode(WorkspaceState.BranchComparisons); + + const id = `${this.branch.id}${this.branch.current ? '+current' : ''}`; + const compareWith = comparisons?.[id]; + if (compareWith != null && typeof compareWith === 'string') { + this._compareWith = { + ref: compareWith, + notation: undefined, + // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions + type: this.view.config.showBranchComparison || ViewShowBranchComparison.Working, + }; + } else { + this._compareWith = compareWith; + } + } + private async updateCompareWith(compareWith: BranchComparison | undefined) { this._compareWith = compareWith; let comparisons = Container.context.workspaceState.get(WorkspaceState.BranchComparisons); - if (comparisons === undefined) { + if (comparisons == null) { comparisons = Object.create(null) as BranchComparisons; }