🐛 Fix shell completions for the fish shell#1069
Conversation
5e44213 to
eda9ccb
Compare
eda9ccb to
b22f193
Compare
|
Thanks for the detailed report and PR! I'll look into this 🙏 |
There was a problem hiding this comment.
Hi @goraje,
Thanks so much for this PR and the detailed report! The issue is clear and it does look like a regression for the fish shell.
In the PR #877, I should have added some more tests to check this behaviour for different shells. I've now gone in and added these tests to your PR: I've created a (minimal) version of docs_src.commands.help.tutorial001 that has Rich tags in its subcommand descriptions, and ran completion tests in the new file test_completion_complete_rich.py to double check that the Rich formatting isn't there. These tests seem to be succeeding just fine on this PR. I double checked on master, and there the test_completion_complete_subcommand_fish fails because of the tab substitution you mentioned.
I saw that you also added tests to double check the functionality of the _sanitize_help_text function. I think that's great - I've just gone ahead and pulled that into its own separate test file for clarity.
So far the behaviour and code look fine to me, but I'll yet perform a final detailed review of all the code changes and will comment here again when I do so.
|
Thank you for looking into that :) I completely agree that the tests didn’t quite belong but I didn’t feel confident enough to modify the project’s structure by adding a test module on my own so thank you for fixing that for me :) |
|
It would be great if this can be merged soon, it's been undermining my use of the |
|
Hi, is it possible to have any update about this issue? Thanks |
There was a problem hiding this comment.
Awesome, thank you! 🚀 🎉
I was able to confirm the bug with the included Docker Compose and then confirm the fix the same way, using the included test file.
Thanks @goraje for the detailed report. 🍰
Thanks @svlandeg for the thorough review. 🙌
This will be available in the next version, 0.15.2 released in the next hours. 🚀
As described in this discussion #1068, recent changes aimed at sanitizing the help text from rich tags during autocompletion generation (#877) have caused problems with proper generation of autocompletions for fish shell, when rich is installed in the environment. The main culprit most likely being the
rich.Console.printmethod that converts the tabs into spaces which results in malformed autocompletes. I propose a different approach to sanitizing the help text, one that allows to perform the removal of tags before the output offormat_completiongets returned, thus allowing to generate a rich tag-free help text, while still being able to pass it to a formatting-preserving output viaclick.echointyper.completion(basically reverting this part of the source to the way it was before the #877 changes).An example of the current behaviour while using
rich.Console.printinvoked intyper.rich_utils.print_with_rich:with an example app of the following structure: