Completions for parameters in quotes, partially quoted or with escaped characters (e.g. whitespace) don't work properly for Fish shell.
I believe the issue is that for fish completion, the incomplete paramater is passed through the COMP_CWORD environment variable and it's expected that it will be contained in COMP_WORDS as the last parameter. However, before doing this match COMP_WORDS is parsed, which quotes and unescapes the parameters, while COMP_CWORD is not causing the match to fail. See code here.
How to replicate
Consider the following command
@click.command()
@click.argument('bar', type=click.Choice(('hello world',)))
def main(bar: str):
pass
Trying to complete foo hello in Fish will correctly return completion for foo hello\ world.
The following incomplete commands will not return any completions
foo hello\
foo "hello
foo "hello"
Environment:
- Python version: 3.13.5
- Click version: 8.2.1
Completions for parameters in quotes, partially quoted or with escaped characters (e.g. whitespace) don't work properly for Fish shell.
I believe the issue is that for fish completion, the incomplete paramater is passed through the
COMP_CWORDenvironment variable and it's expected that it will be contained inCOMP_WORDSas the last parameter. However, before doing this matchCOMP_WORDSis parsed, which quotes and unescapes the parameters, whileCOMP_CWORDis not causing the match to fail. See code here.How to replicate
Consider the following command
Trying to complete
foo helloin Fish will correctly return completion forfoo hello\ world.The following incomplete commands will not return any completions
foo hello\foo "hellofoo "hello"Environment: