diff --git a/src/gitService.ts b/src/gitService.ts index b7e716a..be8ec58 100644 --- a/src/gitService.ts +++ b/src/gitService.ts @@ -96,7 +96,6 @@ export class GitService extends Disposable { private _disposable: Disposable | undefined; private _gitignore: Promise; private _repoWatcher: FileSystemWatcher | undefined; - private _stashWatcher: FileSystemWatcher | undefined; static EmptyPromise: Promise = Promise.resolve(undefined); @@ -125,9 +124,6 @@ export class GitService extends Disposable { this._repoWatcher && this._repoWatcher.dispose(); this._repoWatcher = undefined; - this._stashWatcher && this._stashWatcher.dispose(); - this._stashWatcher = undefined; - this._gitCache.clear(); this._remotesCache.clear(); this._uriCache.clear(); @@ -147,8 +143,7 @@ export class GitService extends Disposable { if (cfg.advanced.caching.enabled) { this._cacheDisposable && this._cacheDisposable.dispose(); - this._repoWatcher = this._repoWatcher || workspace.createFileSystemWatcher('**/.git/index', true, false, true); - this._stashWatcher = this._stashWatcher || workspace.createFileSystemWatcher('**/.git/refs/stash', true, false, true); + this._repoWatcher = this._repoWatcher || workspace.createFileSystemWatcher('**/.git/{index,HEAD,refs/stash}', true, false, true); const disposables: Disposable[] = []; @@ -156,7 +151,6 @@ export class GitService extends Disposable { disposables.push(workspace.onDidChangeTextDocument(this._onTextDocumentChanged, this)); disposables.push(workspace.onDidSaveTextDocument(d => this._removeCachedEntry(d, RemoveCacheReason.DocumentSaved))); disposables.push(this._repoWatcher.onDidChange(this._onRepoChanged, this)); - disposables.push(this._stashWatcher.onDidChange(this._onStashChanged, this)); this._cacheDisposable = Disposable.from(...disposables); } @@ -167,9 +161,6 @@ export class GitService extends Disposable { this._repoWatcher && this._repoWatcher.dispose(); this._repoWatcher = undefined; - this._stashWatcher && this._stashWatcher.dispose(); - this._stashWatcher = undefined; - this._gitCache.clear(); this._remotesCache.clear(); } @@ -216,17 +207,19 @@ export class GitService extends Disposable { }, 1); } - private _onRepoChanged() { + private _onRepoChanged(uri: Uri) { + if (uri !== undefined && uri.path.endsWith('ref/stash')) { + this._fireRepoChange('stash'); + + return; + } + this._gitCache.clear(); this._fireRepoChange(); this._fireGitCacheChange(); } - private _onStashChanged() { - this._fireRepoChange('stash'); - } - private _fireGitCacheChangeDebounced: (() => void) | undefined = undefined; private _fireGitCacheChange() { diff --git a/src/views/gitExplorer.ts b/src/views/gitExplorer.ts index 46b2ce1..54b56c1 100644 --- a/src/views/gitExplorer.ts +++ b/src/views/gitExplorer.ts @@ -47,10 +47,11 @@ export class GitExplorer implements TreeDataProvider { commands.registerCommand('gitlens.gitExplorer.openChangedFileRevisions', this.openChangedFileRevisions, this); commands.registerCommand('gitlens.gitExplorer.applyChanges', this.applyChanges, this); - context.subscriptions.push(this.git.onDidChangeRepo(this.onRepoChanged, this)); + const repoChangedFn = Functions.debounce(this.onRepoChanged, 250); + context.subscriptions.push(this.git.onDidChangeRepo(repoChangedFn, this)); - const fn = Functions.debounce(this.onActiveEditorChanged, 500); - context.subscriptions.push(window.onDidChangeActiveTextEditor(fn, this)); + const editorChangedFn = Functions.debounce(this.onActiveEditorChanged, 500); + context.subscriptions.push(window.onDidChangeActiveTextEditor(editorChangedFn, this)); context.subscriptions.push(workspace.onDidChangeConfiguration(this.onConfigurationChanged, this)); this.onConfigurationChanged();