     if row < 0
       @getFirstPosition()
     else if row > @getLastRow()
-      @getLastPosition()
+      @getEndPosition()
     else
       column = Math.min(Math.max(column, 0), @lineLengthForRow(row))
       if column is position.column


    {rows, characters} = @offsetIndex.totalTo(offset, 'characters')
    if rows > @getLastRow()
      @getLastPosition()
    else
      new Point(rows, offset - characters)


      return new Range(@getFirstPosition(), @getFirstPosition())

    if startRow > lastRow
      return new Range(@getEndPosition(), @getEndPosition())

    startRow = Math.max(0, startRow)
    endRow = Math.min(lastRow, endRow)
