Skip to content

Commit

Permalink
Fix pressing up/down from prompt input going too far
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Sep 12, 2024
1 parent e0edbe3 commit 3656c12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion elia_chat/widgets/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ async def user_chat_message_submitted(
await self.new_user_message(user_message)

@on(PromptInput.CursorEscapingTop)
async def on_cursor_up_from_prompt(self) -> None:
async def on_cursor_up_from_prompt(
self, event: PromptInput.CursorEscapingTop
) -> None:
self.focus_latest_message()

@on(Chatbox.CursorEscapingBottom)
Expand Down
2 changes: 2 additions & 0 deletions elia_chat/widgets/prompt_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ def on_key(self, event: events.Key) -> None:
if self.cursor_location == (0, 0) and event.key == "up":
event.prevent_default()
self.post_message(self.CursorEscapingTop())
event.stop()
elif self.cursor_at_end_of_text and event.key == "down":
event.prevent_default()
self.post_message(self.CursorEscapingBottom())
event.stop()

def on_mount(self):
self.border_title = "Enter your [u]m[/]essage..."
Expand Down

0 comments on commit 3656c12

Please sign in to comment.