When a value with an escape string, for instance my\ file, is passed to a click.ParamType, the incomplete value which is passed to click.ParamType.shell_complete will only be "my\ " instead of my file.
I've updated the issue with a simpler example and direct explanations for expected and actual behavior.
The issue seems to be with how split_arg_string handles slashes and spaces. It's trying to emulate how sys.argv would be populated to apply it to the CWORDS env var, but doesn't get it right in all cases.
Adding some debugging code to ZshComplete.get_completion_args, when my\ f is completed:
os.environ['COMP_WORDS']='example my\\ f'
cwords=['example', 'my\\', 'f']
The shell is passing my\ a, which is the Python string "my\\ f". This is getting parsed into two values "my\\" and "f". Instead, it should get parsed into one value "my\\ f".
You can find some other weird behaviors by tab completing earlier, or with a single opening quote, or within quotes. The splitter should be able to handle these.
That's about the extent of the time I can devote to this for now though. Your best bet for getting this fixed before 8.0 is released is to make a PR.
When a value with an escape string, for instance
my\ file, is passed to a
incompletevalue which is passed to
click.ParamType.shell_completewill only be
"my\ "instead of
my\ fshould be interpreted as the Python string
"my f"and match the first two values.
my\ fis interpreted as the string
"my\\ f"and matches the third value.
The text was updated successfully, but these errors were encountered: