         else if not node
           node = currentNode
           nodeOffset = offset
+
       offset += length
       break if offset > location.offset
 
-    [node, nodeOffset]
+    if node?
+      nodeOffset = lastOffset if index < location.index
+      [node, nodeOffset]
+    else
+      [lastNode, lastOffset]
 
   getNodesForIndex: (index) ->
     nodes = []

    [container, offset]

  findNodeAndOffsetForLocation: (location) ->
    offset = 0
    for currentNode in @getNodesForIndex(location.index)
      length = nodeLength(currentNode)
      if location.offset <= offset + length
        if currentNode.nodeType is Node.TEXT_NODE
          node = currentNode

        nodes.push(node)

    nodes

  getBlockCount: ->
    walker = DOM.walkTree(@element)
    blockCount = 0

    while walker.nextNode()
      node = walker.currentNode
      blockCount++ if nodeIsBlockStartComment(node)

    blockCount

  getLocationRangeAtPoint: ([clientX, clientY]) ->
    if document.caretPositionFromPoint
