kislyuk / argcomplete

Python and tab completion, better together.
https://kislyuk.github.io/argcomplete/
Apache License 2.0
1.39k stars 129 forks source link

zsh: Extra space is added during hierarchy completion (directory or custom) #451

Closed dibalavs closed 7 months ago

dibalavs commented 8 months ago

Hello, Please find example in attachment. test_comp.py.zip

When I try to complete on zsh: ./test_comp.py --dir /ho\<tab> generates: "/home/ " with extra space. As a result - all child items are not available

./test_comp.py --custom /pa\<tab> generates: "/parent/ " also with extra space

When I try to complete on bash - no issues are found.

Environment: lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy

pip show argcomplete Name: argcomplete Version: 3.1.2 Summary: Bash tab completion for argparse Home-page: https://github.com/kislyuk/argcomplete Author: Andrey Kislyuk Author-email: kislyuk@gmail.com License: Apache Software License Location: /home/dybala/.local/lib/python3.10/site-packages Requires: Required-by:

python --version Python 3.10.12

zsh --version zsh 5.8.1 (x86_64-ubuntu-linux-gnu)

bash --version GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)

skovranek commented 7 months ago

I found the proper solution: use DirectoriesCompleter

parser.add_argument(
    'filepath',
    help='specify path to file',
).completer = DirectoriesCompleter
dibalavs commented 7 months ago

Hello, but I am more interesting in custom completer. (see example above). It is working on bash, but have issues on zsh