     stack = []
     range = null
     @scanPair which, direction, from, (event) =>
-      if @getPairState(event) isnt which
-        stack.push(event)
+      eventState = @getEventState(event)
+      if eventState.state isnt which
+        stack.push(eventState)
       else
-        topEvent = stack.pop()
-        if fn(stack, topEvent)
+        if fn(stack, eventState)
           range = event.range
           event.stop()
 
     return range
 
+  spliceStack: (stack, eventState) ->
+    stack.pop()
+
   findCloseForward: (from, {allowForwarding}={}) ->
-    @findPair 'close', 'forward', from, (stack, openEvent) ->
-      unless openEvent?
+    @findPair 'close', 'forward', from, (stack, closeState) =>
+      openState = @spliceStack(stack, closeState)
+      unless openState?
         return true
 
       if stack.length is 0
-        {start} = openEvent.range
+        {start} = openState.range
         start.isEqual(from) or (allowForwarding and start.row is from.row)
 
   findOpenBackward: (from) ->
-    @findPair 'open', 'backward', from, (stack, openEvent) ->
+    @findPair 'open', 'backward', from, (stack, openState) =>
+      @spliceStack(stack, openState)
       stack.length is 0
 
   find: (from, options) ->

    [open, close] = pair
    @pattern = ///(#{_.escapeRegExp(open)})|(#{_.escapeRegExp(close)})///g

  getPairState: ({match}) ->
    switch
      when match[1] then 'open'
      when match[2] then 'close'

class QuoteFinder extends PairFinder
  setPatternForPair: (pair) ->

        scanRange = new Range([0, 0], from)
        scanFunctionName = 'backwardsScanInBufferRange'

    @editor[scanFunctionName] @getPattern(), scanRange, (event) =>
      if not @allowNextLine and (from.row isnt event.range.start.row)
        event.stop()
        return

      if isEscapedCharRange(@editor, event.range)
        return

      fn(event)

