Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Keybindings disabled while searching (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakethekoenig authored Nov 28, 2023
1 parent 8db09db commit cc2a806
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mentat/terminal/prompt_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ def prompt_continuation(
def _setup_bindings(self):
self.bindings = KeyBindings()

@self.bindings.add("s-down")
@self.bindings.add("c-j")
@Condition
def not_searching() -> bool:
return not get_app().layout.is_searching

@self.bindings.add("s-down", filter=not_searching)
@self.bindings.add("c-j", filter=not_searching)
def _(event: KeyPressEvent):
event.current_buffer.insert_text("\n")

@self.bindings.add("enter")
@self.bindings.add("enter", filter=not_searching)
def _(event: KeyPressEvent):
event.current_buffer.validate_and_handle()

Expand All @@ -86,8 +90,8 @@ def _(event: KeyPressEvent):
if suggestion:
event.current_buffer.insert_text(suggestion.text)

@self.bindings.add("c-c")
@self.bindings.add("c-d")
@self.bindings.add("c-c", filter=not_searching)
@self.bindings.add("c-d", filter=not_searching)
def _(event: KeyPressEvent):
if event.current_buffer.text != "":
event.current_buffer.reset()
Expand Down

0 comments on commit cc2a806

Please sign in to comment.