     # gitPlusViewState: @gitPlusView.serialize()
 
   gitStatus: ->
+    @currentPane = atom.workspace.getActivePane()
     process = new BufferedProcess({
       command: 'git'
       args: ['status']

StatusView = require './status-view'

module.exports =
  activate: (state) ->
    @dir = atom.project.getRepo().getWorkingDirectory()
    @commitFilePath = @dir + '/.git/COMMIT_EDITMSG'
    atom.workspaceView.command "git-plus:commit", => @gitStatus()

  deactivate: ->

    @showFile()

  showFile: ->
    atom.workspace.open @commitFilePath(), split: 'right', activatePane: true
    PathWatcher.watch @commitFilePath(), (event) =>
      if event is 'change'
        @commit()

  commit: ->
    process = new BufferedProcess({
      command: 'git'
      args: ['commit', "--file=#{@commitFilePath()}"]
      options:
        cwd: @dir
      stdout: (data) =>
        PathWatcher.closeAllWatchers()
        atom.workspace.destroyActivePane()
        @currentPane.activate()
      stderror: (data) =>
        alert data.toString()
    })
