     @shell = new ShellAdapter(this)
 
     @websocket = new WebSocket("#{serverURI}?token=#{token}")
+    @addOpener()
     @observeSave()
     @handleEvents()
 
+  addOpener: ->
+    atom.workspace.addOpener (uri) =>
+      if @hasPath(uri) and not fs.existsSync(uri)
+        @open(uri)
+
   observeSave: ->
     atom.workspace.observeTextEditors (editor) =>
-      editor.getBuffer()?.onWillSave ({path}) =>
+      editor.onDidSave ({path}) =>
         @save(path)
 
   handleEvents: ->
     messageCallbacks =
       sync: @onRecievedSync
+      open: @onRecievedOpen
       build: @onRecievedBuild
       fetch: @onRecievedFetch
       change: @onRecievedChange

      decoded = new Buffer(content, 'base64').toString('utf8')
      fs.writeFile(localPath, decoded)

  onRecievedRescue: ({message, backtrace}) ->
    console.log 'RESCUE:', message, backtrace



  trash: (path) ->
    @send {command: 'trash', path}

  open: (path) ->
    @send {command: 'open', path}

  save: (path) ->
    atom.project.bufferForPath(path).then (textBuffer) =>
