Skip to content

Commit 387e660

Browse files
committed
Adds fs watching for branch comparisons w/ working
1 parent ba8bf59 commit 387e660

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/views/nodes/compareBranchNode.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import type { Disposable, TreeCheckboxChangeEvent } from 'vscode';
2-
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
1+
import type { TreeCheckboxChangeEvent } from 'vscode';
2+
import { Disposable, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
33
import type { ViewShowBranchComparison } from '../../config';
44
import { GlyphChars } from '../../constants';
55
import type { StoredBranchComparison, StoredBranchComparisons, StoredNamedRef } from '../../constants.storage';
66
import type { GitUri } from '../../git/gitUri';
77
import type { GitBranch } from '../../git/models/branch';
8+
import type { RepositoryFileSystemChangeEvent } from '../../git/models/repository';
89
import type { GitUser } from '../../git/models/user';
910
import type { CommitsQueryResults, FilesQueryResults } from '../../git/queryResults';
1011
import { getCommitsQuery, getFilesQuery } from '../../git/queryResults';
@@ -104,7 +105,24 @@ export class CompareBranchNode extends SubscribeableViewNode<
104105
}
105106

106107
protected override subscribe(): Disposable | Promise<Disposable | undefined> | undefined {
107-
return weakEvent(this.view.onDidChangeNodesCheckedState, this.onNodesCheckedStateChanged, this);
108+
const subscriptions: Disposable[] = [
109+
weakEvent(this.view.onDidChangeNodesCheckedState, this.onNodesCheckedStateChanged, this),
110+
];
111+
112+
if (this.compareWithWorkingTree) {
113+
const repo = this.view.container.git.getRepository(this.uri);
114+
if (repo != null) {
115+
subscriptions.push(
116+
weakEvent(repo.onDidChangeFileSystem, this.onFileSystemChanged, this, [repo.watchFileSystem()]),
117+
);
118+
}
119+
}
120+
121+
return Disposable.from(...subscriptions);
122+
}
123+
124+
private onFileSystemChanged(_e: RepositoryFileSystemChangeEvent) {
125+
void this.triggerChange(true);
108126
}
109127

110128
private onNodesCheckedStateChanged(e: TreeCheckboxChangeEvent<ViewNode>) {

0 commit comments

Comments
 (0)