Skip to content

fix: reenable arrow keys by importing readline #606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions interpreter/terminal_interface/terminal_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
If you were to build a frontend this would be a way to do it
"""

import readline
from .components.code_block import CodeBlock
from .components.message_block import MessageBlock
from .magic_commands import handle_magic_command
Expand Down Expand Up @@ -110,6 +111,9 @@ def terminal_interface(interpreter, message):

if response.strip().lower() == "y":
should_scan_code = True

# remove y/n from history so that user can more easily find last command
readline.remove_history_item(readline.get_current_history_length() - 1)

if should_scan_code:
# Get code language and actual code from the chunk
Expand Down Expand Up @@ -137,6 +141,9 @@ def terminal_interface(interpreter, message):
})
break

# remove y/n from history so that user can more easily find last command
readline.remove_history_item(readline.get_current_history_length() - 1)

# Output
if "output" in chunk:
ran_code_block = True
Expand Down