mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Fixes issue where repo change wasn't fired in some cases
Consolidates repo watching into a single watcher Adds debounce to repo changes in the custom view
This commit is contained in:
@@ -96,7 +96,6 @@ export class GitService extends Disposable {
|
|||||||
private _disposable: Disposable | undefined;
|
private _disposable: Disposable | undefined;
|
||||||
private _gitignore: Promise<ignore.Ignore | undefined>;
|
private _gitignore: Promise<ignore.Ignore | undefined>;
|
||||||
private _repoWatcher: FileSystemWatcher | undefined;
|
private _repoWatcher: FileSystemWatcher | undefined;
|
||||||
private _stashWatcher: FileSystemWatcher | undefined;
|
|
||||||
|
|
||||||
static EmptyPromise: Promise<GitBlame | GitDiff | GitLog | undefined> = Promise.resolve(undefined);
|
static EmptyPromise: Promise<GitBlame | GitDiff | GitLog | undefined> = Promise.resolve(undefined);
|
||||||
|
|
||||||
@@ -125,9 +124,6 @@ export class GitService extends Disposable {
|
|||||||
this._repoWatcher && this._repoWatcher.dispose();
|
this._repoWatcher && this._repoWatcher.dispose();
|
||||||
this._repoWatcher = undefined;
|
this._repoWatcher = undefined;
|
||||||
|
|
||||||
this._stashWatcher && this._stashWatcher.dispose();
|
|
||||||
this._stashWatcher = undefined;
|
|
||||||
|
|
||||||
this._gitCache.clear();
|
this._gitCache.clear();
|
||||||
this._remotesCache.clear();
|
this._remotesCache.clear();
|
||||||
this._uriCache.clear();
|
this._uriCache.clear();
|
||||||
@@ -147,8 +143,7 @@ export class GitService extends Disposable {
|
|||||||
if (cfg.advanced.caching.enabled) {
|
if (cfg.advanced.caching.enabled) {
|
||||||
this._cacheDisposable && this._cacheDisposable.dispose();
|
this._cacheDisposable && this._cacheDisposable.dispose();
|
||||||
|
|
||||||
this._repoWatcher = this._repoWatcher || workspace.createFileSystemWatcher('**/.git/index', true, false, true);
|
this._repoWatcher = this._repoWatcher || workspace.createFileSystemWatcher('**/.git/{index,HEAD,refs/stash}', true, false, true);
|
||||||
this._stashWatcher = this._stashWatcher || workspace.createFileSystemWatcher('**/.git/refs/stash', true, false, true);
|
|
||||||
|
|
||||||
const disposables: Disposable[] = [];
|
const disposables: Disposable[] = [];
|
||||||
|
|
||||||
@@ -156,7 +151,6 @@ export class GitService extends Disposable {
|
|||||||
disposables.push(workspace.onDidChangeTextDocument(this._onTextDocumentChanged, this));
|
disposables.push(workspace.onDidChangeTextDocument(this._onTextDocumentChanged, this));
|
||||||
disposables.push(workspace.onDidSaveTextDocument(d => this._removeCachedEntry(d, RemoveCacheReason.DocumentSaved)));
|
disposables.push(workspace.onDidSaveTextDocument(d => this._removeCachedEntry(d, RemoveCacheReason.DocumentSaved)));
|
||||||
disposables.push(this._repoWatcher.onDidChange(this._onRepoChanged, this));
|
disposables.push(this._repoWatcher.onDidChange(this._onRepoChanged, this));
|
||||||
disposables.push(this._stashWatcher.onDidChange(this._onStashChanged, this));
|
|
||||||
|
|
||||||
this._cacheDisposable = Disposable.from(...disposables);
|
this._cacheDisposable = Disposable.from(...disposables);
|
||||||
}
|
}
|
||||||
@@ -167,9 +161,6 @@ export class GitService extends Disposable {
|
|||||||
this._repoWatcher && this._repoWatcher.dispose();
|
this._repoWatcher && this._repoWatcher.dispose();
|
||||||
this._repoWatcher = undefined;
|
this._repoWatcher = undefined;
|
||||||
|
|
||||||
this._stashWatcher && this._stashWatcher.dispose();
|
|
||||||
this._stashWatcher = undefined;
|
|
||||||
|
|
||||||
this._gitCache.clear();
|
this._gitCache.clear();
|
||||||
this._remotesCache.clear();
|
this._remotesCache.clear();
|
||||||
}
|
}
|
||||||
@@ -216,17 +207,19 @@ export class GitService extends Disposable {
|
|||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onRepoChanged() {
|
private _onRepoChanged(uri: Uri) {
|
||||||
|
if (uri !== undefined && uri.path.endsWith('ref/stash')) {
|
||||||
|
this._fireRepoChange('stash');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._gitCache.clear();
|
this._gitCache.clear();
|
||||||
|
|
||||||
this._fireRepoChange();
|
this._fireRepoChange();
|
||||||
this._fireGitCacheChange();
|
this._fireGitCacheChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onStashChanged() {
|
|
||||||
this._fireRepoChange('stash');
|
|
||||||
}
|
|
||||||
|
|
||||||
private _fireGitCacheChangeDebounced: (() => void) | undefined = undefined;
|
private _fireGitCacheChangeDebounced: (() => void) | undefined = undefined;
|
||||||
|
|
||||||
private _fireGitCacheChange() {
|
private _fireGitCacheChange() {
|
||||||
|
|||||||
@@ -47,10 +47,11 @@ export class GitExplorer implements TreeDataProvider<ExplorerNode> {
|
|||||||
commands.registerCommand('gitlens.gitExplorer.openChangedFileRevisions', this.openChangedFileRevisions, this);
|
commands.registerCommand('gitlens.gitExplorer.openChangedFileRevisions', this.openChangedFileRevisions, this);
|
||||||
commands.registerCommand('gitlens.gitExplorer.applyChanges', this.applyChanges, 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);
|
const editorChangedFn = Functions.debounce(this.onActiveEditorChanged, 500);
|
||||||
context.subscriptions.push(window.onDidChangeActiveTextEditor(fn, this));
|
context.subscriptions.push(window.onDidChangeActiveTextEditor(editorChangedFn, this));
|
||||||
context.subscriptions.push(workspace.onDidChangeConfiguration(this.onConfigurationChanged, this));
|
context.subscriptions.push(workspace.onDidChangeConfiguration(this.onConfigurationChanged, this));
|
||||||
|
|
||||||
this.onConfigurationChanged();
|
this.onConfigurationChanged();
|
||||||
|
|||||||
Reference in New Issue
Block a user