       gutterTile.display = "block"
       gutterTile.zIndex = zIndex
 
-      @updateLinesState(tile, tileStartRow, tileEndRow) if @shouldUpdateLinesState
-      @updateLineNumbersState(gutterTile, tileStartRow, tileEndRow) if @shouldUpdateLineNumbersState
+      @updateLinesState(tile, rowsWithinTile) if @shouldUpdateLinesState
+      @updateLineNumbersState(gutterTile, rowsWithinTile) if @shouldUpdateLineNumbersState
 
       visibleTiles[tileStartRow] = true
       zIndex++

      delete @state.content.tiles[id]
      delete @lineNumberGutter.tiles[id]

  updateLinesState: (tileState, startRow, endRow) ->
    tileState.lines ?= {}
    visibleLineIds = {}
    row = startRow
    while row < endRow
      line = @model.tokenizedLineForScreenRow(row)
      unless line?
        throw new Error("No line exists for row #{row}. Last screen row: #{@model.getLastScreenRow()}")

      visibleLineIds[line.id] = true
      if tileState.lines.hasOwnProperty(line.id)
        lineState = tileState.lines[line.id]
        lineState.screenRow = row
        lineState.decorationClasses = @lineDecorationClassesForRow(row)
      else
        tileState.lines[line.id] =
          screenRow: row
          text: line.text
          openScopes: line.openScopes
          tags: line.tags

      isVisible = isVisible and @showLineNumbers
    isVisible

  isSoftWrappedRow: (bufferRow, screenRow) ->
    return false if screenRow is 0

    @model.bufferRowForScreenRow(screenRow - 1) is bufferRow

  updateLineNumbersState: (tileState, screenRows) ->
    tileState.lineNumbers ?= {}
    visibleLineNumberIds = {}

    for screenRow in screenRows
      bufferRow = @model.bufferRowForScreenRow(screenRow)
      softWrapped = @isSoftWrappedRow(bufferRow, screenRow)
      decorationClasses = @lineNumberDecorationClassesForRow(screenRow)
      foldable = @model.isFoldableAtScreenRow(screenRow)
      id = @model.tokenizedLineForScreenRow(screenRow).id

      tileState.lineNumbers[id] = {screenRow, bufferRow, softWrapped, decorationClasses, foldable}
      visibleLineNumberIds[id] = true

    for id of tileState.lineNumbers
      delete tileState.lineNumbers[id] unless visibleLineNumberIds[id]
