Skip the first reload event.

This commit is contained in:
joshaber
2016-03-25 10:49:22 -04:00
parent 694d288e16
commit 7294b95b70
2 changed files with 15 additions and 2 deletions

View File

@@ -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()

View File

@@ -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()