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

Re: [PATCH] _parameters: complete namespace only after ${



> 2026/03/26 16:56, I wrote:
> 
> Parameter names like .foo.bar (or just .foo or foo.) are
> allowed only inside ${...}. But
> 
> % echo $.t<TAB>
> 
> gives $.term.bg etc. The patch below fixes this problem,

The patch was for not completing '.term' etc. for $<TAB>. But
parameter names with dot(s) need be completed in various other
places such as:

% unset <TAB>
% <TAB>		# at command position
% echo foo${<TAB>
etc.

So names with dots need be filtered out only if we are completing
immediately after a '$'.

# IPREFIX is just '$' in the case of ${#<TAB> or ${~<TAB>


diff --git a/Completion/Zsh/Type/_parameters b/Completion/Zsh/Type/_parameters
index d92197b42..557bed26b 100644
--- a/Completion/Zsh/Type/_parameters
+++ b/Completion/Zsh/Type/_parameters
@@ -14,8 +14,8 @@ local -a expl pattern=( -g \* ) normal described verbose faked fakes tmp
 zstyle -t ":completion:${curcontext}:parameters" prefix-needed &&
     [[ $PREFIX != [_.]* ]] &&
         pfilt='[_.]*'
-# names containing a dot are allowed only within ${ }
-[[ $IPREFIX != \${* ]] && pfilt+='|*.*'
+# names containing a dot are not allowd after '$'
+[[ $IPREFIX = *\$ ]] && pfilt+='|*.*'
 
 _description parameters expl parameter
 zparseopts -D -K -E g:=pattern





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