 
   didStopScrolling: ->
     @state.content.scrollingVertically = false
-    if @scrollingTile?
-      @scrollingTile = null
+    if @scrollingTileId?
+      @scrollingTileId = null
       @shouldUpdateTilesState = true
       @shouldUpdateLineNumbersState = true
       @shouldUpdateCustomGutterDecorationState = true

    @state.content.backgroundColor = if @model.isMini() then null else @backgroundColor
    @state.content.placeholderText = if @model.isEmpty() then @model.getPlaceholderText() else null

  updateTilesState: ->
    return unless @startRow? and @endRow? and @lineHeight?

    linesPerTile = Math.floor(@height / @lineHeight / @tileCount)
    linesPerTile = Math.max(1, linesPerTile)

    startIndex = Math.max(
      0, Math.floor(@startRow / linesPerTile) - @tileOverdrawMargin
    )
    endIndex = Math.min(
      Math.ceil(@model.getScreenLineCount() / linesPerTile),
      Math.ceil(@endRow / linesPerTile) + @tileOverdrawMargin
    )

    visibleTiles = {}
    for index in [startIndex...endIndex]
      startRow = Math.floor(index * linesPerTile)
      endRow = Math.ceil(Math.min(@model.getScreenLineCount(), (index + 1) * linesPerTile))

      isNewTile = not @state.content.tiles.hasOwnProperty(index)
      tile = @state.content.tiles[index] ?= {}
      tile.top = (index * linesPerTile * @lineHeight) - @scrollTop
      tile.height = linesPerTile * @lineHeight
      tile.newlyCreated = isNewTile
      tile.display = "block"

      @updateLinesState(tile, startRow, endRow)

      visibleTiles[index] = true

    for index, tile of @state.content.tiles
      continue if visibleTiles.hasOwnProperty(index)

      if index is @scrollingTile
        tile.display = "none"
      else
        delete @state.content.tiles[index]


  updateLinesState: (tileState, startRow, endRow) ->

      @emitDidUpdateState()

  setScrollingTileId: (tileId) ->
    if @scrollingTileId isnt tileId
      @scrollingTileId = tileId
      @didStartScrolling()

  setBaseCharacterWidth: (baseCharacterWidth) ->
