       isVisible = isVisible and @showLineNumbers
     isVisible
 
-  updateLineNumbersState: (tileState, startRow, endRow) ->
+  isSoftWrappedRow: (bufferRow, screenRow) ->
+    return false if screenRow is 0
+
+    @model.bufferRowForScreenRow(screenRow - 1) is bufferRow
+
+  updateLineNumbersState: (tileState, screenRows) ->
     tileState.lineNumbers ?= {}
     visibleLineNumberIds = {}
 
-    if startRow > 0
-      rowBeforeStartRow = startRow - 1
-      lastBufferRow = @model.bufferRowForScreenRow(rowBeforeStartRow)
-    else
-      lastBufferRow = null
-
-    if endRow > startRow
-      bufferRows = @model.bufferRowsForScreenRows(startRow, endRow - 1)
-      for bufferRow, i in bufferRows
-        if bufferRow is lastBufferRow
-          softWrapped = true
-        else
-          lastBufferRow = bufferRow
-          softWrapped = false
-
-        screenRow = startRow + i
-        decorationClasses = @lineNumberDecorationClassesForRow(screenRow)
-        foldable = @model.isFoldableAtScreenRow(screenRow)
-        id = @model.tokenizedLineForScreenRow(screenRow).id
-
-        tileState.lineNumbers[id] = {screenRow, bufferRow, softWrapped, top, decorationClasses, foldable}
-        visibleLineNumberIds[id] = true
+    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]

      gutterTile.display = "block"
      gutterTile.zIndex = zIndex

      @updateLinesState(tile, tileStartRow, tileEndRow) if @shouldUpdateLinesState
      @updateLineNumbersState(gutterTile, tileStartRow, tileEndRow) if @shouldUpdateLineNumbersState

      visibleTiles[tileStartRow] = true
      zIndex++

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

  updateLinesState: (tileState, screenRows) ->
    tileState.lines ?= {}
    visibleLineIds = {}
    for screenRow in screenRows
      line = @model.tokenizedLineForScreenRow(screenRow)
      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 = screenRow
        lineState.decorationClasses = @lineDecorationClassesForRow(screenRow)
      else
        tileState.lines[line.id] =
          screenRow: screenRow
          text: line.text
          openScopes: line.openScopes
          tags: line.tags
