From 7294b95b70dd2b4be55a970e5e399eda5289b9fd Mon Sep 17 00:00:00 2001 From: joshaber Date: Fri, 25 Mar 2016 10:49:22 -0400 Subject: [PATCH] Skip the first reload event. --- src/git-repository-async.js | 8 +++++++- src/git-repository.coffee | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/git-repository-async.js b/src/git-repository-async.js index 943a98841..668183ba7 100644 --- a/src/git-repository-async.js +++ b/src/git-repository-async.js @@ -1056,9 +1056,15 @@ export default class GitRepositoryAsync { } } + // TextBuffers will emit a reload event when they're first loaded. We don't + // need to refresh in that case. + let firstReload = true bufferSubscriptions.add( buffer.onDidSave(refreshStatusForBuffer), - buffer.onDidReload(refreshStatusForBuffer), + buffer.onDidReload(() => { + if (!firstReload) refreshStatusForBuffer() + firstReload = false + }), buffer.onDidChangePath(refreshStatusForBuffer), buffer.onDidDestroy(() => { bufferSubscriptions.dispose() diff --git a/src/git-repository.coffee b/src/git-repository.coffee index 0513c2293..bc4f57161 100644 --- a/src/git-repository.coffee +++ b/src/git-repository.coffee @@ -448,7 +448,14 @@ class GitRepository bufferSubscriptions = new CompositeDisposable bufferSubscriptions.add buffer.onDidSave(getBufferPathStatus) - bufferSubscriptions.add buffer.onDidReload(getBufferPathStatus) + + # TextBuffers will emit a reload event when they're first loaded. We don't + # need to refresh in that case. + firstReload = true + bufferSubscriptions.add buffer.onDidReload(-> + getBufferPathStatus() unless firstReload + firstReload = false + ) bufferSubscriptions.add buffer.onDidChangePath(getBufferPathStatus) bufferSubscriptions.add buffer.onDidDestroy => bufferSubscriptions.dispose()