Conversation

andrewleech

Summary

Fix aiorepl to properly handle the Enter key when stdin is in raw terminal mode by accepting both CR (0x0D) and LF (0x0A) for command execution.

Problem

When using aiorepl with MicroPython ports that put stdin in raw mode (such as the updated unix port using pyexec), the Enter key sends CR (0x0D) instead of LF (0x0A). The original aiorepl only handled LF, requiring users to use Ctrl+Enter instead of Enter to execute commands.

Solution

  • Handle both CR (0x0D) and LF (0x0A) for command execution
  • Improve handling of various newline sequences (CRLF, double-LF, double-CR) to prevent double-execution
  • Preserve original behavior in paste mode

Test plan

  • Verify Enter key now executes commands in raw terminal mode
  • Verify CRLF sequences don't cause double-execution
  • Verify paste mode still works correctly
  • Test with unix MicroPython port using new pyexec REPL

🤖 Generated with Claude Code

Handle both CR (0x0D) and LF (0x0A) for command execution to ensure
compatibility with raw terminal mode where Enter sends CR instead of LF.

This fixes the issue where aiorepl required Ctrl+Enter instead of
just Enter to execute commands when used with MicroPython ports that
put stdin in raw mode (such as the updated unix port using pyexec).

Also improves handling of various newline sequences (CRLF, double-LF,
double-CR) to prevent double-execution of commands.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Andrew Leech <[email protected]>
Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.