Skip to content

aiorepl: Fix Enter key handling in raw terminal mode#1016

Merged
dpgeorge merged 1 commit into
micropython:masterfrom
andrewleech:fix-aiorepl-raw-terminal
Jul 11, 2026
Merged

aiorepl: Fix Enter key handling in raw terminal mode#1016
dpgeorge merged 1 commit into
micropython:masterfrom
andrewleech:fix-aiorepl-raw-terminal

Conversation

@andrewleech

Copy link
Copy Markdown
Contributor

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

@dpgeorge dpgeorge left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks.

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 <noreply@anthropic.com>
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
@dpgeorge dpgeorge force-pushed the fix-aiorepl-raw-terminal branch from 5ab36ae to bb9506c Compare July 11, 2026 13:30
@dpgeorge dpgeorge merged commit bb9506c into micropython:master Jul 11, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants