   getEndTileRow: ->
     @constrainRow(@tileForRow(@endRow))
 
+  isValidScreenRow: (screenRow) ->
+    screenRow >= 0 and screenRow < @model.getScreenLineCount()
+
   getScreenRows: ->
     startRow = @getStartTileRow()
     endRow = @constrainRow(@getEndTileRow() + @tileSize)

    zIndex = 0

    for tileStartRow in [@tileForRow(endRow)..@tileForRow(startRow)] by -@tileSize
      tileEndRow = @constrainRow(tileStartRow + @tileSize)
      rowsWithinTile = []

      while screenRowIndex >= 0

    screenRows = [startRow...endRow]
    if longestScreenRow = @model.getLongestScreenRow()
      screenRows.push(longestScreenRow)
    if @screenRowsToMeasure?
      screenRows.push(@screenRowsToMeasure...)

    screenRows = screenRows.filter @isValidScreenRow.bind(this)
    screenRows.sort (a, b) -> a - b
    _.uniq(screenRows, true)

