     fileName = "[#{file.vmName}]#{plainPath}"
     return fileName
 
-  saveEditorHistory: ->
-    log "NOT IMPLEMENTED YET"
+  updateEditorStatus:(file, lastSavedContent)->
+    fileName   = FSHelper.plainPath file.path
+    # get current AceViews
+    aceAppView = KD.singletons.appManager.get("Ace").getView()
+    {ace} = aceAppView.aceViews[fileName]
+    ace.lastSavedContents = lastSavedContent
+    unless ace.getContents() is lastSavedContent
+      ace.emit "FileContentChanged"
+    else
+      ace.emit "FileContentSynced"
+
+  removeLocalContents:->
+    for key in @storage.getLocalStorageKeys()
+      if key.indexOf("koding-editor") > -1
+        delete window.localStorage[key]

    @initializeListeners()

  initializeListeners: ->
    status = KD.remote

    @on "LocalContentSynced", (file)->
      log "LocalContentSynced : #{file.path}"

    @on "LocalContentCouldntSynced", (file)->
      log "LocalContentSynced : #{file.path}"

    status.on "reconnected", =>
      return  if @synStarted
      @synStarted = yes
      @syncLocalContentIfDiffExists (err)=>

  removeFromSaveArray: (file) ->
    fileName = @getFileFullPath file
    index = @filesToSave.indexOf fileName
    return  unless index > -1
    @filesToSave.splice index, 1
    @storage.setValue "saveRequestedFiles", @filesToSave

  patchFileIfDiffExist: (file, localContent, cb, callCounter = 0)->
    KD.singletons.vmController.info file.vmName, @utils.getTimedOutCallback (err, vm, info)=>
      return cb err unless info.state is "RUNNING"
      file.fetchContents (err, content)=>
        if content and not err
          newContent = @getPatchedContent content, localContent
          unless content is localContent
            file.save localContent, (err, res)=>
              return cb err if err
              @removeFromSaveArray file
              @removeFileContentFromLocalStorage file
              @updateEditorStatus file, localContent
              @emit "LocalContentSynced", file
              cb null, file
          else
            @removeFromSaveArray file
            cb null, file
    ,=>
      ++callCounter
      if callCounter > 5
        @emit "VMNotResponding", file
      else
        @patchFileIfDiffExist file, localContent, cb, callCounter

  getPatchedContent: (originalContent, localContent)->
    dmp = new diff_match_patch
