 
     @screenLineIterator.seekToBufferPosition(range.end)
     endScreenRow = @screenLineIterator.getScreenRow() + 1
-    endBufferRow = @screenLineIterator.getBufferEnd().row
+    endBufferRow = @buffer.clipPosition(@screenLineIterator.getBufferEnd()).row + 1
 
     {startScreenRow, endScreenRow, startBufferRow, endBufferRow}
 

    @screenLineIndex.getScreenLineCount()

  getRightmostScreenPosition: ->
    @screenLineIndex.getScreenPositionWithMaxLineLength()

  lineLengthForScreenRow: (screenRow) ->
    @screenLineIndex.lineLengthForScreenRow(screenRow)

    lines.join('\n')

  getScreenLines: (startRow=0, endRow=@getScreenLineCount()) ->
    startRow = Math.max(startRow, 0)
    endRow = Math.min(endRow, @getScreenLineCount())
    screenLines = []
    @screenLineIterator.seekToScreenRow(startRow)
    containingTags = @decorationIterator.seek(@screenLineIterator.getBufferStart())
