   @extend(false)
   allowForwarding: true
   allowNextLine: false
+
+  getPairState: ({matchText, range, match}) ->
+    @pairStateInBufferRange(range, matchText)
+
+  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)]
 
 class DoubleQuote extends Quote
   @extend(false)

  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)]

  getFilters: (from) ->
    filters = []


  findOpen: (from) ->
    stack = []
    openRange = null
    filters = @getFilters(from)

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

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

  findClose: (from) ->
    stack = []
    closeRange = null
    filters = @getFilters(from)

    isValidOpen = ({range}) =>
      openStart = range.start
      if @allowForwarding
        openStart.row is from.row
      else
        openStart.isEqual(from)

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

      {range, stop} = event
      if @getPairState(event) is 'open'
        stack.push(event)
      else
        openEvent = stack.pop()
        if stack.length is 0 and ((not openEvent?) or isValidOpen(openEvent))
          closeRange = range
          stop()
    closeRange

  getPairInfo: (from) ->
    pairInfo = null
