Repository navigation
Replies: 1 comment
|
Your diagnosis is right. I reckon I've found exactly where it breaks. ZshComplete.format_completion runs the escape pass first: the help text goes through _sanitize_help_text(escape(item.help)).escape() replaces every ":" with a backslash-prefixed form for zsh's _describe, and only then does _sanitize_help_text hand that already-mangled string to rich_render_text, which is just console.render() joined back to text. Rich only substitutes a :shortcode: while the colons are intact, so with backslashes in front of them the pattern no longer matches and the text is emitted as-is: the raw shortcode with backslashes, exactly what you're seeing. Zsh is the only shell affected as far as I can judge. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
First Check
Example Code
Description
Describe the bug
In zsh completion, help text containing a Rich emoji shortcode such as⚠️ isn't rendered. The raw shortcode is shown, with backslashes in it.
Cause
ZshComplete.format_completion in typer/_completion_classes.py calls _sanitize_help_text(escape(item.help)). escape() backslash-escapes : for zsh's _describe before Rich renders the text. Rich then no longer matches⚠️ . Bash and fish don't hit this, because bash doesn't escape and fish calls _sanitize_help_text on the raw text.
Possible fix
Render with Rich first, then escape for zsh:
I have a branch with this change and a test that checks both the emoji rendering and that a literal : in the output is still escaped. It's in #1988.
Operating System
Linux, macOS
Operating System Details
No response
Project Version
0.27.3.
Python Version
3.13.17
Additional Context
No response
All reactions