On 11/21/22 17:30, Bart Schaefer wrote:
I still can't reproduce this
Weird.. With the symlink I can now on all my machines (arch, debian 11, mint 21), and even the official(?) docker:
% docker run --rm -it zshusers/zsh:5.9 # ln -s /tmp /foo # autoload -U compinit; compinit # compdef '_canonical_paths -N files files /tmp/My\ File' cmd # cmd <Tab> /foo/My File /tmp/My\ File foo/My File tmp/My File (output split to several lines, to make it more readable)
diff --git a/Completion/Unix/Type/_canonical_paths b/Completion/Unix/Type/_canonical_paths index a8fbbb524..b2eff84df 100644 --- a/Completion/Unix/Type/_canonical_paths +++ b/Completion/Unix/Type/_canonical_paths @@ -42,7 +42,7 @@ _canonical_paths_add_paths () { # ### Ideally, this codepath would do what the 'if' above does, # ### but telling compadd to pretend the "word on the command line" # ### is ${"the word on the command line"/$origpref/$canpref}. - matches+=(${${(M)files:#$canpref*}/$canpref/$origpref}) + matches+=( "${(@)${(@M)files:#$canpref*}/$canpref/$origpref}" ) fi for subdir in $expref?*(@); do
This didn't fix the problem. But applying the same escaping "hack"(?) as in the if-case above, did:
--- a/Completion/Unix/Type/_canonical_paths +++ b/Completion/Unix/Type/_canonical_paths @@ -30,19 +30,17 @@ canpref+=$rltrim [[ $expref == *[^/] && $canpref == */ ]] && origpref+=/ + local -a tmp_buffer + compadd -A tmp_buffer "$__gopts[@]" -a files # Append to $matches the subset of $files that matches $canpref. if [[ $canpref == $origpref ]]; then # This codepath honours any -M matchspec parameters. - () { - local -a tmp_buffer - compadd -A tmp_buffer "$__gopts[@]" -a files - matches+=( "${(@)tmp_buffer/$canpref/$origpref}" ) - } + matches+=( "${(@)tmp_buffer/$canpref/$origpref}" ) else # ### Ideally, this codepath would do what the 'if' above does, # ### but telling compadd to pretend the "word on the command line" # ### is ${"the word on the command line"/$origpref/$canpref}. - matches+=(${${(M)files:#$canpref*}/$canpref/$origpref}) + matches+=(${${(M)tmp_buffer:#$canpref*}/$canpref/$origpref}) fi for subdir in $expref?*(@); do
Attachment:
OpenPGP_0x39BEE2916D330138.asc
Description: OpenPGP public key
Attachment:
OpenPGP_signature
Description: OpenPGP digital signature