Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completion(fish): add back ; as line endings in fish script #2570

Merged
merged 2 commits into from Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -7,6 +7,7 @@ Unreleased

- Fix issue with regex flags in shell completion. :issue:`2581`
- Bash version detection issues a warning instead of an error. :issue:`2574`
- Fix issue with completion script for Fish shell. :issue:`2567`


Version 8.1.6
Expand Down
2 changes: 1 addition & 1 deletion docs/shell-completion.rst
Expand Up @@ -62,7 +62,7 @@ program name. This uses ``foo-bar`` as an example.

.. code-block:: fish

eval (env _FOO_BAR_COMPLETE=fish_source foo-bar)
_FOO_BAR_COMPLETE=fish_source foo-bar | source

This is the same file used for the activation script method
below. For Fish it's probably always easier to use that method.
Expand Down
28 changes: 14 additions & 14 deletions src/click/shell_completion.py
Expand Up @@ -167,25 +167,25 @@ def __getattr__(self, name: str) -> t.Any:
"""

_SOURCE_FISH = """\
function %(complete_func)s
function %(complete_func)s;
set -l response (env %(complete_var)s=fish_complete COMP_WORDS=(commandline -cp) \
COMP_CWORD=(commandline -t) %(prog_name)s)
COMP_CWORD=(commandline -t) %(prog_name)s);

for completion in $response
set -l metadata (string split "," $completion)
for completion in $response;
set -l metadata (string split "," $completion);

if test $metadata[1] = "dir"
__fish_complete_directories $metadata[2]
else if test $metadata[1] = "file"
__fish_complete_path $metadata[2]
else if test $metadata[1] = "plain"
echo $metadata[2]
end
end
end
if test $metadata[1] = "dir";
__fish_complete_directories $metadata[2];
else if test $metadata[1] = "file";
__fish_complete_path $metadata[2];
else if test $metadata[1] = "plain";
echo $metadata[2];
end;
end;
end;

complete --no-files --command %(prog_name)s --arguments \
"(%(complete_func)s)"
"(%(complete_func)s)";
"""


Expand Down