       @doc.mergeLines(firstLine, firstLine.next)
   )
 
-forceTrailingNewline = ->
+_forceTrailingNewline = ->
   unless @doc.lines.last?.trailingNewline
-    # Can't do this.insertAt since still within the doAt call, this \n will alreayd be recorded by trackDelta
-    insertAt.call(this, this.getLength(), "\n")
+    # Can't do this.insertAt since still within the doAt call, this \n will already been recorded by _trackDelta
+    _insertAt.call(this, this.getLength(), "\n")
 
 # formatAt (Number index, Number length, String name, Mixed value) ->
-formatAt = (index, length, name, value) ->
+_formatAt = (index, length, name, value) ->
   @selection.preserve(index, 0, =>
     [line, offset] = @doc.findLineAtOffset(index)
     while line? and length > 0


  formatAt: (index, length, name, value, options = {}) ->
    options = _.defaults(options, DEFAULT_API_OPTIONS)
    doAt.call(this, =>
      formatAt.call(this, index, length, name, value)
    , options)
    
  getDelta: ->
    checkUpdate.call(this)
    return @doc.toDelta()

  getLength: ->
    return this.getDelta().endLength

  getSelection: ->
    checkUpdate.call(this)
    return @selection.getRange()

  insertAt: (index, text, formatting = {}, options = {}) ->
    options = _.defaults(options, DEFAULT_API_OPTIONS)
    doAt.call(this, =>
      insertAt.call(this, index, text, formatting)
      forceTrailingNewline.call(this)
    , options)

  setDelta: (delta) ->

    )
  )

_trackDelta = (fn, options) ->
  oldDelta = @doc.toDelta()
  oldIndex = @savedRange?.start.index
  fn()
