Skip to content

Conversation

sandyscott
Copy link

Changed this to use stdin.buffer instead of stdin. Now catches and ignores the consecutive line ending characters within 20ms of the previous.

Changed this to use stdin.buffer instead of stdin. Now catches and ignores the second consecutive line ending character within 20ms
Use double instead of single quotes for empty buffer literal
@dlech
Copy link

dlech commented Oct 31, 2022

Changed this to use stdin.buffer instead of stdin.

Is this going to cause problems with multi-byte unicode characters since it now reads one byte instead of one unicode character?

@sandyscott
Copy link
Author

Having thought about this a bit more, this is going to get messy fast. The aiorepl server would need knowledge of the terminal's character encoding to properly decode the characters. UTF-8 is not a safe assumption: if the terminal is using an 8-bit character set and sends any single-byte character above 0xBF this could cause the server to hang while it waits for the second byte that will never come. The code would also need a fairly significant restructure to separate the decoding from the actions. I think the simpler fix in #560 is a safer way to fix the specific issue I encountered - that windows line endings are interpreted as two presses of the enter key.

@sandyscott sandyscott closed this Nov 1, 2022
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.

2 participants