-applyDelta = (delta) ->
+_applyDelta = (delta) ->
   _.defer( =>
     delta.apply((index, text) =>
       this.shiftCursors(index, text.length)

    )
  )


buildCursor = (userId, name, color) ->
  cursor = @container.ownerDocument.createElement('span')
  cursor.setAttribute('contenteditable', false)
  cursor.classList.add('cursor')

      return if cursor == undefined || cursor.index < index
      if (cursor.index >= index)
        if length > 0
          _setCursor.call(this, cursor.userId, cursor.index + length, cursor.name, cursor.color)   # Insert
        else
          # Delete needs to handle special case: start|cursor|end vs normal case: start|end|cursor
          _setCursor.call(this, cursor.userId, cursor.index + Math.max(length, index - cursor.index), cursor.name, cursor.color)
    )

  setCursor: (userId, index, name, color) ->
    _setCursor.call(this, userId, index, name, color)
    clearTimeout(@cursors[userId].timer)
    @cursors[userId].timer = setTimeout( =>
      cursorName = @container.querySelector("##{Scribe.Editor.CURSOR_PREFIX}#{userId} .cursor-name")
      cursorName.classList.add('hidden') if cursorName
      @cursors[userId].timer = null
    , Scribe.MultiCursorManager.CURSOR_NAME_TIMEOUT)

  clearCursors: ->
    while @container.firstChild?
