diff --git a/spec/git-spec.coffee b/spec/git-spec.coffee index 0226c7cac..b4e049db8 100644 --- a/spec/git-spec.coffee +++ b/spec/git-spec.coffee @@ -259,6 +259,10 @@ describe "GitRepository", -> editor.getBuffer().emitter.emit 'did-change-path' expect(statusHandler.callCount).toBe 1 + it "stops listening to the buffer when the repository is destroyed (regression)", -> + atom.project.getRepositories()[0].destroy() + expect(-> editor.save()).not.toThrow() + describe "when a project is deserialized", -> [buffer, project2] = [] diff --git a/src/git-repository.coffee b/src/git-repository.coffee index 43a31e8aa..463fe279f 100644 --- a/src/git-repository.coffee +++ b/src/git-repository.coffee @@ -412,6 +412,8 @@ class GitRepository bufferSubscriptions.add buffer.onDidDestroy => bufferSubscriptions.dispose() @subscriptions.remove(bufferSubscriptions) + @subscriptions.add(bufferSubscriptions) + return # Subscribes to editor view event. checkoutHeadForEditor: (editor) ->