Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: autoload path completion with expansions



On Sun, Sep 5, 2021 at 11:54 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> +      if [[ $PREFIX[1] = [$/~] ]] && _files; then
>         # Autoload by absolute path

Turns out this doesn't do the right thing when $PREFIX contains a
valid relative directory name (such as "." or ".." among other
things).

Slightly different patch against the original source.

diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset
index d3304bed0..058842378 100644
--- a/Completion/Zsh/Command/_typeset
+++ b/Completion/Zsh/Command/_typeset
@@ -101,9 +101,9 @@ if [[ "$state" = vars_eq ]]; then
     elif (( $+opt_args[-w] )); then
       _wanted files expl 'zwc file' _files -g '*.zwc(-.)' && ret=0
     elif [[ $service = autoload || -n $opt_args[(i)-[uU]] ]]; then
-      if [[ $PREFIX[1] = [/~] ]]; then
+      if [[ ${"${(e)PREFIX}"[1]} = [/~] ]] && _files; then
        # Autoload by absolute path
-       _files && ret=0
+       ret=0
       else
          args=(${^fpath}/*(-.:t))
          # Filter out functions already loaded or marked for autoload.




Messages sorted by: Reverse Date, Date, Thread, Author