def find_backwards(self, sub, in_current_line=False, ignore_case=False, count=1):
        if in_current_line:
            before_cursor = self.current_line_before_cursor[::-1]
        else:
            before_cursor = self.text_before_cursor[::-1]

        flags = re.IGNORECASE if ignore_case else 0
        iterator = re.finditer(re.escape(sub[::-1]), before_cursor, flags)

        try:
            for i, match in enumerate(iterator):
                if i + 1 == count:
                    return - match.start(0) - len(sub)
        except StopIteration:
            pass
Checkout onto a new branch with no history.
dataset/ETHPy150Open jonathanslenders/python-prompt-toolkit/prompt_toolkit/document.py/Document.find_backwards--crossover with--dataset/ETHPy150Open bloomberg/phabricator-tools/py/phl/phlgit_checkout.py/orphan