Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Zsh completions with colons #2846

Open
wants to merge 1 commit into
base: release-8.2.0
Choose a base branch
from

Conversation

the-13th-letter
Copy link

@the-13th-letter the-13th-letter commented Jan 17, 2025

The Zsh completion script uses different primitives to load completion items into Zsh depending on whether a completion item has a description or not.

  • For items with descriptions, the Zsh _describe function is used, which expects item plus description pairs as values, separated by a colon. In turn, any colon within the item must be escaped.
  • For items without descriptions, the Zsh compadd builtin is used, which expects literal items, without escaping. Actually escaping colons in the item will corrupt the item.

click's built-in Zsh completion class does not escape colons in the item. So it only handles the second case correctly, not the first; see e.g. #2703. This PR fixes this by choosing a suitable serialization, for each item separately, according to the abovementioned escaping requirements.

Since at its core this is an issue of two systems not agreeing on the format for exchanging data, and since we principally control both systems, we could fix this on either side. However, because the Zsh completion script is typically already installed in the user's shell, which is both harder to detect within click and harder to change or influence, we opt to change the click side instead, even if it the serialization needs to be more irregular.

Resolves #2703


  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
    • “docs“ presumably not applicable in this case?
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
    • Would cause merge issues because CHANGES.rst has no entry yet for post-8.2.0 changes.
  • Add .. versionchanged:: entries in any relevant code docs.
    • Not applicable in this case?

@Rowlando13
Copy link
Collaborator

Thanks for taking the time to submit this PR. We will review this.

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