       for decoration in decorations
         if decoration.isType('line') or decoration.isType('line-number')
           @updateLineDecorationCaches(decoration, range)
+        else if decoration.isType('highlight')
+          visibleHighlights[decoration.id] = @updateHighlightState(decoration, range)
+
+    for id of @state.content.highlights
+      unless visibleHighlights[id]
+        delete @state.content.highlights[id]
+
+    @emitter.emit 'did-update-state'
 
   updateLineDecorationCaches: (decoration, range) ->
     marker = decoration.getMarker()

        pixelRect = @pixelRectForScreenRange(cursor.getScreenRange())
        pixelRect.width = @baseCharacterWidth if pixelRect.width is 0
        @state.content.cursors[cursor.id] = pixelRect

    @emitter.emit 'did-update-state'

  updateHighlightsState: ->
    return unless @hasRequiredMeasurements()

    startRow = @computeStartRow()
    endRow = @computeEndRow()
    visibleHighlights = {}

    for decoration in @model.getHighlightDecorations()
      continue unless decoration.getMarker().isValid()
      screenRange = decoration.getMarker().getScreenRange()
      if screenRange.intersectsRowRange(startRow, endRow - 1)
        if screenRange.start.row < startRow
          screenRange.start.row = startRow
          screenRange.start.column = 0
        if screenRange.end.row >= endRow
          screenRange.end.row = endRow
          screenRange.end.column = 0
        continue if screenRange.isEmpty()

        visibleHighlights[decoration.id] = true

        @state.content.highlights[decoration.id] ?= {
          flashCount: 0
          flashDuration: null
          flashClass: null
        }
        highlightState = @state.content.highlights[decoration.id]
        highlightState.class = decoration.getProperties().class
        highlightState.deprecatedRegionClass = decoration.getProperties().deprecatedRegionClass
        highlightState.regions = @buildHighlightRegions(screenRange)

    for id of @state.content.highlights
      unless visibleHighlights.hasOwnProperty(id)
        delete @state.content.highlights[id]

    @emitter.emit 'did-update-state'


      @updateDecorations()
      @updateLineNumbersState()
    if decoration.isType('highlight')
      @updateDecorations()
    if decoration.isType('overlay')
      @updateOverlaysState()

