 module.exports =
 class OccurrenceManager
   patterns: null
+  markerOptions: {invalidate: 'inside'}
+  decorationOptions: {type: 'highlight', class: 'vim-mode-plus-occurrence-match'}
 
   constructor: (@vimState) ->
     {@editor, @editorElement} = @vimState


  # Markers
  # -------------------------
  hasMarkers: ->
    @markerLayer.getMarkerCount() > 0


    @patterns = []

    @markerLayer = @editor.addMarkerLayer()
    @decorationLayer = @editor.decorateMarkerLayer(@markerLayer, @decorationOptions)

    # @patterns is single source of truth (SSOT)
    # All maker create/destroy/css-update is done by reacting @patters's change.
    # -------------------------
    @onDidChangePatterns ({newPattern}) =>
      if newPattern
        @markBufferRangeByPattern(newPattern)
      else
        @clearMarkers()

    # Update css on every marker update.
    @markerLayer.onDidUpdate =>
      @editorElement.classList.toggle("has-occurrence", @hasMarkers())

  markBufferRangeByPattern: (pattern) ->
    for range in scanEditor(@editor, pattern)
      @markerLayer.markBufferRange(range, @markerOptions)

  # Callback get passed following object
  # - newPattern: can be undefined on reset event
