 
     fail = () ->
       $linenosCode.html "Failed to save".replace /(.)/g, '$1<br>'
+      edit()
 
     lock null, 'Saving...'
     $.ajax({
       method
       url
       contentType: 'application/octet-stream'
-      data: currentContent
+      data: currentSrc
     }).always(always).done(done).fail(fail)
     false
 
-  edit = (content) ->
-    content ?= getDomContent()
-    $list.hide()
-    $linenosCode.html "Esc - #{metaKeyName}+s - Shift+#{metaKeyName}+s".replace /(.)/g, '$1<br>'
-    $editorCode.html content
-    $editorCode.attr('contentEditable', 'true').focus()
-    $editorCode.on 'blur', keepFocus
+  edit = (content = contentSrc) ->
+    $content.html content
+    $content.attr('contentEditable', 'true').focus()
+    $content.on 'blur', keepFocus
     $body.addClass 'editing'
     $body.off 'keydown', disableSave
     $body.on 'keydown', maybeSave
     $body.on 'keydown', maybeCancelEditing
 
-  lock = (content, lines = []) ->
-    content ?= getDomContent()
+  lock = (content = contentSrc, lines = [], language) ->
     if Array.isArray lines
       if lines.length is 0
         linenosCount = content.split('\n').length

$ () ->
  currentContent = ''
  $window = $ window
  $body = $ window.document.body
  $theme = $ '#theme'

      filename = filename.join '.'

    done = (body, status, xhr) ->
      setContent body
      if language?
        try
          high = hljs.highlight language, body
        catch e
          high = {value: body}
      else
        high = hljs.highlightAuto body
        if high.language?
          history.replaceState undefined, undefined, "\##{filename}.#{high.language}"
      lock high.value

    fail = () ->
