   # Yank the selection; always exits; either deletes the selection or collapses it; returns the yanked text.
   yank: (args = {}) ->
     @yankedText = @selection.toString()
-    console.log "yank:", @yankedText if @debug
+    console.log "yank:", @yankedText if @debug  This is used to detect, after a movement, whether the selection has changed.
 
     if args.deleteFromDocument or @options.deleteFromDocument
       @selection.deleteFromDocument()

    else
      @selection.modify @alterMethod, movement...

  # Return a simple camparable value which will be different for different selections.
  hashSelection: ->
    [ @element?.selectionStart, @selection.toString().length ].join "/"

  # Call a function; return true if the selection changed.
  selectionChanged: (func) ->


  pasteClipboard: (direction) ->
    @paste (text) =>
      if text
        # We use the following heuristic: if the text ends in a newline character, then it's a line-oriented
        # paste, and should be pasted in at a line break.
        if /\n$/.test text
          @runMovement backward, "lineboundary"
          @runMovement forward, "line" if direction == forward
          DomUtils.simulateTextEntry @element, text
          @runMovement backward, "line"
        else
          DomUtils.simulateTextEntry @element, text

  openLine: (direction) ->
    @runMovement direction, "lineboundary"
