Skip to content

Commit

Permalink
completion(fish): add back ; as line endings in fish script (#2570)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism authored Aug 17, 2023
2 parents a260ca6 + a955c77 commit 6e1f6d3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 6e1f6d3

Please sign in to comment.