From d11e30579b3203bc179018dacd91441ce37a4fff Mon Sep 17 00:00:00 2001 From: joshaber Date: Wed, 27 Apr 2016 17:17:09 -0400 Subject: [PATCH] Manually emit the change event. --- src/git-repository.coffee | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/git-repository.coffee b/src/git-repository.coffee index 28455c983..a92a03a89 100644 --- a/src/git-repository.coffee +++ b/src/git-repository.coffee @@ -166,10 +166,7 @@ class GitRepository # # Returns a {Disposable} on which `.dispose()` can be called to unsubscribe. onDidChangeStatuses: (callback) -> - @async.onDidChangeStatuses => - @branch = @async?.branch - @statusesByPath = {} - callback() + @emitter.on 'did-change-statuses', callback ### Section: Repository Details @@ -494,7 +491,23 @@ class GitRepository # # Returns a promise that resolves when the repository has been refreshed. refreshStatus: -> - asyncRefresh = @async.refreshStatus() + statusesChanged = false + subscription = @async.onDidChangeStatuses -> + subscription?.dispose() + subscription = null + + statusesChanged = true + + asyncRefresh = @async.refreshStatus().then => + subscription?.dispose() + subscription = null + + @branch = @async?.branch + @statusesByPath = {} + + if statusesChanged + @emitter.emit 'did-change-statuses' + syncRefresh = new Promise (resolve, reject) => @handlerPath ?= require.resolve('./repository-status-handler')