Skip to content

Commit 6e1f6d3

Browse files
authored
completion(fish): add back ; as line endings in fish script (#2570)
2 parents a260ca6 + a955c77 commit 6e1f6d3

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Unreleased
77

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

1112

1213
Version 8.1.6

docs/shell-completion.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ program name. This uses ``foo-bar`` as an example.
6262

6363
.. code-block:: fish
6464
65-
eval (env _FOO_BAR_COMPLETE=fish_source foo-bar)
65+
_FOO_BAR_COMPLETE=fish_source foo-bar | source
6666
6767
This is the same file used for the activation script method
6868
below. For Fish it's probably always easier to use that method.

src/click/shell_completion.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,25 +167,25 @@ def __getattr__(self, name: str) -> t.Any:
167167
"""
168168

169169
_SOURCE_FISH = """\
170-
function %(complete_func)s
170+
function %(complete_func)s;
171171
set -l response (env %(complete_var)s=fish_complete COMP_WORDS=(commandline -cp) \
172-
COMP_CWORD=(commandline -t) %(prog_name)s)
172+
COMP_CWORD=(commandline -t) %(prog_name)s);
173173
174-
for completion in $response
175-
set -l metadata (string split "," $completion)
174+
for completion in $response;
175+
set -l metadata (string split "," $completion);
176176
177-
if test $metadata[1] = "dir"
178-
__fish_complete_directories $metadata[2]
179-
else if test $metadata[1] = "file"
180-
__fish_complete_path $metadata[2]
181-
else if test $metadata[1] = "plain"
182-
echo $metadata[2]
183-
end
184-
end
185-
end
177+
if test $metadata[1] = "dir";
178+
__fish_complete_directories $metadata[2];
179+
else if test $metadata[1] = "file";
180+
__fish_complete_path $metadata[2];
181+
else if test $metadata[1] = "plain";
182+
echo $metadata[2];
183+
end;
184+
end;
185+
end;
186186
187187
complete --no-files --command %(prog_name)s --arguments \
188-
"(%(complete_func)s)"
188+
"(%(complete_func)s)";
189189
"""
190190

191191

0 commit comments

Comments
 (0)