     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())


    @screenLineIterator.seekToBufferPosition(range.end)
    endScreenRow = @screenLineIterator.getScreenRow() + 1
    endBufferRow = @screenLineIterator.getBufferEnd().row

    {startScreenRow, endScreenRow, startBufferRow, endBufferRow}



    metadata = @spatialTokenIterator.getMetadata()
    if metadata?.void
      if options?.clipDirection is 'forward'
        throw new Error('TODO: Not implemented. Support void tokens followed by valid screen positions, such as soft wrap indents.')
      else
        screenPosition = @spatialTokenIterator.getScreenStart()
    else if comparePoints(screenPosition, @spatialTokenIterator.getScreenEnd()) <= 0
      if (metadata?.atomic and
          comparePoints(screenPosition, @spatialTokenIterator.getScreenStart()) > 0 and
