       replacementText = null
       iterator(match, matchRange, { stop, replace })
       @change(matchRange, replacementText) if replacementText
-      return unless global and recurse
+      return unless global and keepLooping
 
 
 _.extend(Buffer.prototype, EventEmitter)

        matchStartIndex++
        matchEndIndex++

      if global and recurse
        traverseRecursively(text, matchEndIndex, endIndex, lengthDelta)

    startIndex = @characterIndexForPosition(range.start)
    endIndex = @characterIndexForPosition(range.end)
    traverseRecursively(@getText(), startIndex, endIndex, 0)

  backwardsScanInRange: (regex, range, iterator) ->
    global = regex.global


    matches.reverse()

    keepLooping = true
    stop = -> keepLooping = false
    replacementText = null
    replace = (text) -> replacementText = text

