 
   insertAt: (index, text, emitEvent = true) ->
     this.doSilently( =>
-      delta = this.trackDelta( =>
-        @selection.preserve( =>
+      @selection.preserve( =>
+        delta = this.trackDelta( =>
           this.keepNormalized( =>
             @doc.insertText(index, text)
           )
         )
-      )
-      this.emit(ScribeEditor.events.TEXT_CHANGE, delta) if emitEvent
+        this.emit(ScribeEditor.events.TEXT_CHANGE, delta) if emitEvent
+        return delta
+      )
     )
     
   setSelection: (range) ->

            newLine = @doc.appendLine(lineNode)
            lineNode = lineNode.nextSibling
        )
        @selection.update(true)
      )
      this.emit(ScribeEditor.events.TEXT_CHANGE, delta) if emitEvent and !delta.isIdentity()
    )



  # format: (Number index, Number length, String name, Mixed value) ->
  format: (index, length, name, value, emitEvent = true) ->
    this.doSilently( =>
      @selection.preserve( =>
        delta = this.trackDelta( =>
          this.keepNormalized( =>
            @doc.format(index, length, name, value)
          )
        )
        this.emit(ScribeEditor.events.TEXT_CHANGE, delta) if emitEvent
        return delta
      )
    )

  getDelta: ->
