 _ = require 'underscore-plus'
 {
   isEscapedCharRange
+  getEndOfLineForBufferRow
   scanBufferRow
 } = require './utils'
 

  spliceStack: (stack, eventState) ->
    stack.pop()

  findCloseForward: (from) ->
    @findPair 'close', 'forward', from, (stack, closeState) =>
      openState = @spliceStack(stack, closeState)
      unless openState?
        return true

      if stack.length is 0
        {start} = openState.range
        start.isEqual(from) or (@allowForwarding and start.row is from.row)

  findOpenBackward: (from) ->
    @findPair 'open', 'backward', from, (stack, openState) =>
      @spliceStack(stack, openState)
      stack.length is 0

  find: (from) ->
    closeRange = @findCloseForward(from)
    if closeRange?
      @closeRange = closeRange
      openRange = @findOpenBackward(closeRange.end)

    if closeRange? and openRange?
      {

    # it is forwarding pair, so stoppable is not @allowForwarding
    findingNonForwardingClosingQuote = (this instanceof QuoteFinder) and which is 'close' and not @allowForwarding

    @editor[functionName] pattern, scanRange, (event) =>
      return if isEscapedCharRange(@editor, event.range)
      return unless @filterEvent(event)

      eventState = @getEventState(event)

      if eventState.state isnt which
