<commit_before>"""
Search related key bindings.
"""
from __future__ import unicode_literals
from ..key_bindings import key_binding
from prompt_toolkit.application.current import get_app
from prompt_toolkit.filters import is_searching, control_is_searchable, Condition
from prompt_toolkit import search

__all__ = [
    'abort_search',
    'accept_search',
    'start_reverse_incremental_search',
    'start_forward_incremental_search',
    'reverse_incremental_search',
    'forward_incremental_search',
    'accept_search_and_accept_input',
]


@key_binding(filter=is_searching)
def abort_search(event):
    """
    Abort an incremental search and restore the original
    line.
    (Usually bound to ControlG/ControlC.)
    """
    search.stop_search()


@key_binding(filter=is_searching)
def accept_search(event):
    """
    When enter pressed in isearch, quit isearch mode. (Multiline
    isearch would be too complicated.)
    (Usually bound to Enter.)
    """
    search.accept_search()


@key_binding(filter=control_is_searchable)
def start_reverse_incremental_search(event):
    """
    Enter reverse incremental search.
    (Usually ControlR.)
    """
    search.start_search(direction=search.SearchDirection.BACKWARD)


@key_binding(filter=control_is_searchable)
def start_forward_incremental_search(event):
    """
    Enter forward incremental search.
    (Usually ControlS.)
    """
    search.start_search(direction=search.SearchDirection.BACKWARD)
<commit_msg>search: fix direction of incremental search<commit_after>"""
Search related key bindings.
"""
from __future__ import unicode_literals
from ..key_bindings import key_binding
from prompt_toolkit.application.current import get_app
from prompt_toolkit.filters import is_searching, control_is_searchable, Condition
from prompt_toolkit import search

__all__ = [
    'abort_search',
    'accept_search',
    'start_reverse_incremental_search',
    'start_forward_incremental_search',
    'reverse_incremental_search',
    'forward_incremental_search',
    'accept_search_and_accept_input',
]


@key_binding(filter=is_searching)
def abort_search(event):
    """
    Abort an incremental search and restore the original
    line.
    (Usually bound to ControlG/ControlC.)
    """
    search.stop_search()


@key_binding(filter=is_searching)
def accept_search(event):
    """
    When enter pressed in isearch, quit isearch mode. (Multiline
    isearch would be too complicated.)
    (Usually bound to Enter.)
    """
    search.accept_search()


@key_binding(filter=control_is_searchable)
def start_reverse_incremental_search(event):
    """
    Enter reverse incremental search.
    (Usually ControlR.)
    """
    search.start_search(direction=search.SearchDirection.BACKWARD)


@key_binding(filter=control_is_searchable)
def start_forward_incremental_search(event):
    """
    Enter forward incremental search.
    (Usually ControlS.)
    """
    search.start_search(direction=search.SearchDirection.FORWARD)

{'fraction_non_alphanumeric': 0.08889634350888963, 'fraction_numerical': 0.0, 'mean_word_length': 4.77906976744186, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3391665', 'n_tokens_mistral': 912, 'n_tokens_neox': 872, 'n_words': 193}