   supportCount: true
 
   # Return 'open' or 'close'
-  getPairState: ({matchText, range, match}) ->
-    switch match.length
-      when 2
-        @pairStateInBufferRange(range, matchText)
-      when 3
-        switch
-          when match[1] then 'open'
-          when match[2] then 'close'
-
-  pairStateInBufferRange: (range, char) ->
-    text = getLineTextToBufferPosition(@editor, range.end)
-    escapedChar = _.escapeRegExp(char)
-    bs = backSlashPattern
-    patterns = [
-      "#{bs}#{bs}#{escapedChar}"
-      "[^#{bs}]?#{escapedChar}"
-    ]
-    pattern = new RegExp(patterns.join('|'))
-    ['close', 'open'][(countChar(text, pattern) % 2)]
+  getPairState: ({match}) ->
+    switch
+      when match[1] then 'open'
+      when match[2] then 'close'
 
   getFilters: (from) ->
     filters = []


  findOpen: (from) ->
    stack = []
    found = null

    filters = @getFilters(from)

    findPair @editor, from, @pair, 'backward', (event) =>
      {range, stop} = event
      return if filters.some((filter) -> filter(event))

      if @getPairState(event) is 'close'
        stack.push({range})
      else
        stack.pop()
        found = range if stack.length is 0
      stop() if found?
    found

  findClose: (from) ->
    stack = []
    found = null

    filters = @getFilters(from)

    findPair @editor, from, @pair, 'forward', (event) =>
      {range, stop} = event
      return if filters.some((filter) -> filter(event))

      if @getPairState(event) is 'open'
        stack.push({range})
      else
        entry = stack.pop()
        if stack.length is 0
          if (openStart = entry?.range.start)
            if @allowForwarding
              return if openStart.row isnt from.row
            else
              return if openStart.isGreaterThan(from)
          found = range
      stop() if found?
    found

  getPairInfo: (from) ->
    pairInfo = null

  pattern = getPatternForPair(pair)
  switch direction
    when 'forward'
      scanRange = new Range(from, editor.buffer.getEndPosition())
      editor.scanInBufferRange(pattern, scanRange, fn)
    when 'backward'
      scanRange = new Range([0, 0], from)
      editor.backwardsScanInBufferRange(pattern, scanRange, fn)

# Take start point of matched range.
backSlashPattern = _.escapeRegExp('\\')
