Skip to content

Commit d6eb5b6

Browse files
sandyscottjimmo
authored andcommitted
aiorepl: Ignore duplicate LFLF after converting CRLF from Windows.
The regular REPL uses the uncooked input, but aiorepl reads from sys.stdin which is cooked. The result is that if the client sends a CRLF, aiorepl will see LFLF. This ignores a second LF in quick succession from the first. Signed-off-by: Jim Mussared <[email protected]>
1 parent 50b7aca commit d6eb5b6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: micropython/aiorepl/aiorepl.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ async def task(g=None, prompt="--> "):
110110
t = time.ticks_ms()
111111
if c < 0x20 or c > 0x7E:
112112
if c == 0x0A:
113-
# CR
113+
# LF
114+
# If the previous character was also LF, and was less
115+
# than 20 ms ago, this was likely due to CRLF->LFLF
116+
# conversion, so ignore this linefeed.
117+
if pc == 0x0A and time.ticks_diff(t, pt) < 20:
118+
continue
114119
sys.stdout.write("\n")
115120
if cmd:
116121
# Push current command.

0 commit comments

Comments
 (0)