From 3c1529e6bc12118ff5a83b2f81fc52f625367736 Mon Sep 17 00:00:00 2001 From: Peter Dragun Date: Wed, 19 Jul 2023 09:06:03 +0200 Subject: [PATCH 1/2] add back semicolons in fish script --- src/click/shell_completion.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/click/shell_completion.py b/src/click/shell_completion.py index af4a57a23..dc9e00b9b 100644 --- a/src/click/shell_completion.py +++ b/src/click/shell_completion.py @@ -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)"; """ From a955c77719981af390b6d2349730c590c80e11e9 Mon Sep 17 00:00:00 2001 From: Peter Dragun Date: Mon, 24 Jul 2023 09:47:11 +0200 Subject: [PATCH 2/2] update fish enabling script --- CHANGES.rst | 1 + docs/shell-completion.rst | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 3662e5696..8cae133f2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 diff --git a/docs/shell-completion.rst b/docs/shell-completion.rst index ebf73c323..9ea20294c 100644 --- a/docs/shell-completion.rst +++ b/docs/shell-completion.rst @@ -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.