|
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'; |
3 | 3 | import type { ViewShowBranchComparison } from '../../config'; |
4 | 4 | import { GlyphChars } from '../../constants'; |
5 | 5 | import type { StoredBranchComparison, StoredBranchComparisons, StoredNamedRef } from '../../constants.storage'; |
6 | 6 | import type { GitUri } from '../../git/gitUri'; |
7 | 7 | import type { GitBranch } from '../../git/models/branch'; |
| 8 | +import type { RepositoryFileSystemChangeEvent } from '../../git/models/repository'; |
8 | 9 | import type { GitUser } from '../../git/models/user'; |
9 | 10 | import type { CommitsQueryResults, FilesQueryResults } from '../../git/queryResults'; |
10 | 11 | import { getCommitsQuery, getFilesQuery } from '../../git/queryResults'; |
@@ -104,7 +105,24 @@ export class CompareBranchNode extends SubscribeableViewNode< |
104 | 105 | } |
105 | 106 |
|
106 | 107 | 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); |
108 | 126 | } |
109 | 127 |
|
110 | 128 | private onNodesCheckedStateChanged(e: TreeCheckboxChangeEvent<ViewNode>) { |
|
0 commit comments