From bd63ae7e18f649e22ace799e6d366efe4029dc80 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 1 Sep 2022 23:13:09 -0500 Subject: [PATCH 1/2] =?UTF-8?q?Don=E2=80=99t=20add=20a=20space=20after=20a?= =?UTF-8?q?ttrs=20completion=20in=20zsh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This matches the behavior of bash. We don’t want to add a space after completion on attrs. Uses -S. Switches to new compadd style comppletions instead of _describe. Shouldn’t have any negative issues from what I can tell. --- misc/zsh/completion.zsh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/misc/zsh/completion.zsh b/misc/zsh/completion.zsh index e702c721e..e86984168 100644 --- a/misc/zsh/completion.zsh +++ b/misc/zsh/completion.zsh @@ -10,14 +10,15 @@ function _nix() { local -a suggestions declare -a suggestions for suggestion in ${res:1}; do - # FIXME: This doesn't work properly if the suggestion word contains a `:` - # itself - suggestions+="${suggestion/ /:}" + suggestions+=("${suggestion%% *}") done + local -a args if [[ "$tpe" == filenames ]]; then - compadd -f + args+=('-f') + elif [[ "$tpe" == attrs ]]; then + args+=('-S' '') fi - _describe 'nix' suggestions + compadd -J nix "${args[@]}" -a suggestions } -_nix "$@" +# _nix "$@" From dd3cd1a16740cb20ba00a36f8b3cf8f813e7480f Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 2 Sep 2022 10:50:02 -0500 Subject: [PATCH 2/2] Apply suggestions from code review --- misc/zsh/completion.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/zsh/completion.zsh b/misc/zsh/completion.zsh index e86984168..f9b3dca74 100644 --- a/misc/zsh/completion.zsh +++ b/misc/zsh/completion.zsh @@ -21,4 +21,4 @@ function _nix() { compadd -J nix "${args[@]}" -a suggestions } -# _nix "$@" +_nix "$@"