kislyuk / argcomplete

Python and tab completion, better together.
https://kislyuk.github.io/argcomplete/
Apache License 2.0
1.39k stars 129 forks source link

Use ` as escape character in PowerShell #434

Closed bebound closed 1 year ago

bebound commented 1 year ago

Related issue: https://github.com/Azure/azure-cli/issues/26526

Argcomplete escape the special_chars with \ when get completion. The result is incorrect on PowerShell. For example. space will be converted to \, but it should be `

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 60.00% and project coverage change: -0.17 :warning:

Comparison is base (f3f856b) 81.29% compared to head (048c7d5) 81.13%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #434 +/- ## =========================================== - Coverage 81.29% 81.13% -0.17% =========================================== Files 10 10 Lines 770 774 +4 =========================================== + Hits 626 628 +2 - Misses 144 146 +2 ``` | [Impacted Files](https://app.codecov.io/gh/kislyuk/argcomplete/pull/434?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrey+Kislyuk) | Coverage Δ | | |---|---|---| | [argcomplete/finders.py](https://app.codecov.io/gh/kislyuk/argcomplete/pull/434?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrey+Kislyuk#diff-YXJnY29tcGxldGUvZmluZGVycy5weQ==) | `91.90% <60.00%> (-0.53%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

kislyuk commented 1 year ago

Thanks. It would be best to have a unit test for this, but we've never managed to get powershell to run in unit tests. I trust you have tested this and it works for you.

kislyuk commented 1 year ago

Actually, I think there is a problem that will have to be corrected before I release this. I don't think the presence of PSModulePath is a sufficiently positive signal that we're running in powershell. It might be set in other shells through some sort of common configuration mechanism.

Instead, the variable _ARGCOMPLETE_SHELL should be set to powershell in https://github.com/kislyuk/argcomplete/blob/develop/argcomplete/shell_integration.py#L101-L107 and its value matched instead of PSModulePath.

kislyuk commented 1 year ago

@bebound I fixed the issue with the environment variables. Will you please confirm that the fix actually worked for you and report the version of powershell that you used?

bebound commented 1 year ago

Thans for the fix in https://github.com/kislyuk/argcomplete/commit/fe6ecb5a369cb70c318ef13ef0ede96afb667cb2 It works on PS 5.1.22621.1778.