Repository navigation
Conversation
On Windows, sys.stdout translates "\n" to "\r\n". Shells such as Git Bash (MINGW64) keep the trailing "\r" as part of each completion, which shows up as "^M" after every suggestion. Write completions with "\n" line endings regardless of platform. Fixes aws#9135 Co-authored-by: Baradhan Madhavan <222307534+Baradhan-Madhu@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available: Fixes #9135
Description of changes:
On Windows,
sys.stdouttranslates\nto\r\n. Whenaws_completeris used from Git Bash (MINGW64), bash keeps the trailing\ras part of each completion, so every suggestion shows up with a^Mafter it.autocomplete()now reconfigures stdout to write\nline endings before printing completions. On Linux/macOS this is a no-op.Verified on Windows 11 by piping
COMP_LINE="aws ec" aws_completerthroughod -c:e c 2 \r \n e c 2 - i n s t a n c e - c o n n e c t \r \n ...e c 2 \n e c 2 - i n s t a n c e - c o n n e c t \n ...Added a unit test that simulates a CRLF-translating stdout. It fails without the change and passes with it.
tests/unit/autocompleteandtests/functional/autocomplete/test_main.pypass (233 tests).By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.