       @emitDidUpdateState()
 
   setScrollingTileId: (tileId) ->
-    if @scrollingTile isnt tileId
-      @scrollingTile = tileId
+    if @scrollingTileId isnt tileId
+      @scrollingTileId = tileId
       @didStartScrolling()
 
   setBaseCharacterWidth: (baseCharacterWidth) ->


  didStopScrolling: ->
    @state.content.scrollingVertically = false
    if @scrollingTile?
      @scrollingTile = 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

  # REFACTOR: This should be a @field rather than a function.
  linesPerTile: ->
    linesPerTile = Math.floor(@height / @lineHeight / @tileCount)
    Math.max(1, linesPerTile)

  tileForRow: (row) ->
    row - (row % @linesPerTile())

  getVisibleTileRange: ->
    startTileRow = Math.max(0, @tileForRow(@startRow) - @tileOverdrawMargin)
    endTileRow = Math.min(
      @tileForRow(@model.getScreenLineCount()),
      @tileForRow(@endRow) + @tileOverdrawMargin
    )

    [startTileRow..endTileRow]

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

    visibleTiles = {}
    for startRow in @getVisibleTileRange() by @linesPerTile()
      endRow = Math.min(@model.getScreenLineCount(), startRow + @linesPerTile())

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

      @updateLinesState(tile, startRow, endRow)

      visibleTiles[startRow] = true

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

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


  updateLinesState: (tileState, startRow, endRow) ->
