   # Try to merge the given selection with this selection
   #
   # @param [Selection] selection the selection to merge to
-  # @param [Rte] rte a Rich text editor instance
   #
   # @example
   #   1                 2                   3
   #   [  left selection ][  right selection ]
   #    becomes
   #   [           right selection           ]
-  merge: (selection, rte) ->
-    if @.style != selection.style
+  merge: (selection) ->
+    if @ == selection
+      return
+    if @style != selection.style
       return false
     if @atLeftOf selection
       leftSel = @
       rightSel = selection
-    else
+    else if selection.atLeftOf @
       leftSel = selection
       rightSel = @
+    else
+      return
 
     # unbind words from left selection, remove it from selection list
     # expand the selection at right to the left end of previous left selection

        throw new Error "Expecting numbers as arguments"
      if not (rte instanceof Rte)
        throw new Error "Expecting an rte instance as third argument, got #{rte}"
      @startPos = @_relativeFromAbsolute start, rte
      @endPos = @_relativeFromAbsolute end, rte
      @style = style

      @left = rte.getWord @startPos.word
      @right = rte.getWord @endPos.word

      @left.left.push @
      @right.right.push @

      rte._rte.selections.push @

    else throw new Error "Wrong set of parameters #{start}, #{end}, #{rte}, #{style}"

    if not _.isUndefined(style)
      @style = style

    @startPos.lt = @endPos.lt = (selection) ->
      @word < selection.word or (@word == selection.word and @pos <= selection.pos)


    @left = null
    @right = null

  # Unbind selection from word
  bind: ->
    @left.left.push(@)
    @right.right.push(@)

  # Clone the current selection and apply style
  # @parameter [String] style the new style
  clone: (style) ->
    newSel = new Selection 0, 0, @rte, style
    newSel.unbind()
    newSel.startPos = @startPos
    newSel.endPos = @endPos
    newSel.left = @left
    newSel.right = @right
    newSel.bind()

    newSel

# Class describing the Rich Text Editor type
#
