 # @param [Rte] rte an rte instance
 relativeFromAbsolute = (position, rte)->
     index = 0
-
     while position > 0
       if index >= rte._rte.words.length
-        return {word: index, pos: 0}
+        position = 0
+        break
       if rte._rte.words[index].word.length > position
-        return {word: index, pos: position}
+        break
       else
         position -= rte._rte.words[index].word.length
         index += 1
+
     return {word: index, pos: position}
 
 # Function that translates an index from start (absolute position) into a

    {word: word, pos: pos}

  # Set the style of the selection and try to extend as much
  # as possible existing ones
  #
  setStyle: (selection, style)->
    if not selection.isValid()
      throw new Error "Invalid selection"

    selection.style = style or ""

    # Link the boundary words to selection
    leftWord = selection.left
    rightWord = selection.right

    # Merge left…
    for tmpSelection in leftWord.right when tmpSelection


  # Merge two words at position
  #
  # @param [Integer] n position of word where to perform merge. The merge will
  # be done with the word at right (if any)
  #
  merge: (index) ->
    if 0 <= index < @_rte.words.length
