 
     addSelection = (log) ->
       range = buildRandomRange()
-      log "Adding selection at #{range}"
+      log "editor.addSelectionForBufferRange(#{JSON.stringify(range.serialize())})"
       editor.addSelectionForBufferRange(range)
 
     changeSelection = (log) ->
+      index = _.random(0, editor.getSelections().length - 1)
       range = buildRandomRange()
-      selection = getRandomElement(editor.getSelections())
-      log "Changing selection from #{selection.getBufferRange()} to #{range}"
-      selection.setBufferRange(range)
+      log "editor.getSelections()[#{index}].setBufferRange(#{JSON.stringify(range.serialize())})"
+      editor.getSelections()[index].setBufferRange(range)
 
     destroySelection = (log) ->
-      selection = getRandomElement(editor.getSelections())
-      log "Destroying selection at #{selection.getBufferRange()}"
-      selection.destroy()
+      index = _.random(0, editor.getSelections().length - 1)
+      log "editor.getSelections()[#{index}].destroy()"
+      editor.getSelections()[index].destroy()
 
     changeLineDecorations = (log) ->
       actions = [addLineDecoration]

    changeScrollTop = (log) ->
      scrollHeight = presenterParams.lineHeight * editor.getScreenLineCount()
      newScrollTop = Math.max(0, _.random(0, scrollHeight - presenterParams.height))
      log "Changing scrollTop: #{newScrollTop}"
      presenterParams.scrollTop = newScrollTop
      presenter.setScrollTop(newScrollTop)

    changeScrollLeft = (log) ->
      scrollWidth = presenter.computeScrollWidth()
      newScrollLeft = Math.max(0, _.random(0, scrollWidth - presenterParams.contentFrameWidth))
      log "Changing scrollLeft: #{newScrollLeft}"
      presenterParams.scrollLeft = newScrollLeft
      presenter.setScrollLeft(newScrollLeft)

    changeHeight = (log) ->
      scrollHeight = presenterParams.lineHeight * editor.getScreenLineCount()
      newHeight = _.random(30, scrollHeight * 1.5)
      log "Chaning height: #{newHeight}"
      presenterParams.height = newHeight
      presenter.setHeight(newHeight)

    changeContentFrameWidth = (log) ->
      scrollWidth = presenter.computeScrollWidth()
      newContentFrameWidth = _.random(100, scrollWidth * 1.5)
      log "Chaning contentFrameWidth: #{newContentFrameWidth}"
      presenterParams.contentFrameWidth = newContentFrameWidth
      presenter.setContentFrameWidth(newContentFrameWidth)

    toggleSoftWrap = (log) ->
      softWrapped = not editor.isSoftWrapped()
      log "Changing softWrapped: #{softWrapped}"
      editor.setSoftWrapped(softWrapped)

    insertText = (log) ->
      range = buildRandomRange()
      text = buildRandomText()
      log "Inserting text in range #{range}: #{text}"
      editor.setTextInBufferRange(range, text)

    changeCursors = (log) ->

      else if Math.random() > .2
        options.onlyHead = true

      log """
        marker = editor.markBufferRange(#{JSON.stringify(range.serialize())})
        editor.decorateMarker(marker, #{JSON.stringify(options)})
      """

      marker = editor.markBufferRange(range)
      editor.decorateMarker(marker, options)

    changeLineDecoration = (log) ->
      index = _.random(0, editor.getLineDecorations().length - 1)
      range = buildRandomRange()
      log "editor.getLineDecorations()[#{index}].getMarker().setBufferRange(#{JSON.stringify(range.serialize())})"
      editor.getLineDecorations()[index].getMarker().setBufferRange(range)

    destroyLineDecoration = (log) ->
      index = _.random(0, editor.getLineDecorations().length - 1)
      log "editor.getLineDecorations()[#{index}].destroy()"
      editor.getLineDecorations()[index].destroy()

    buildRandomPoint = ->
      row = _.random(0, buffer.getLastRow())
