zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: modifiers with _expand and keep-prefix
@ 2004-08-07 14:58 Oliver Kiddle
  0 siblings, 0 replies; only message in thread
From: Oliver Kiddle @ 2004-08-07 14:58 UTC (permalink / raw)
  To: Zsh workers

With the keep-prefix style set, if a modifier in an expansion has the
effect of removing or changing the prefix, _expand adds it back. For
example:

% echo ~/.z*(:t)<tab>

expands to:

% echo ~.zcompdump ~.zfunc ~.zshenv ...

Fix is below. I check whether ${exp[1]} starts with $pre. Before
allowing the code which does exp=( ${opre}${^exp#${pre}} ). Makes sense
to check that the old prefix can be removed before adding the old.

Strictly speaking the test should be something like:
  [[ -z $exp[(r)$pre*] ]]
but we already have a test which assumes that what is right for
${exp[1]} is right for the rest of the array.

Oliver

Index: Completion/Base/Completer/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_expand,v
retrieving revision 1.8
diff -u -r1.8 _expand
--- Completion/Base/Completer/_expand	7 Jul 2003 09:48:46 -0000	1.8
+++ Completion/Base/Completer/_expand	7 Aug 2004 14:40:36 -0000
@@ -133,8 +133,9 @@
 
   if [[ -n "$epre" && $#epre -eq 1 ]]; then
     pre="${(q)epre[1]}"
-    [[ "$tmp" != changed || $#exp -gt 1 ||
-       "${opre}${exp[1]#${pre}}" != "$word" ]] && exp=( ${opre}${^exp#${pre}} )
+    [[ ( "$tmp" != changed || $#exp -gt 1 ||
+       "${opre}${exp[1]#${pre}}" != "$word" ) && "${exp[1]}" = $pre* ]] &&
+       exp=( ${opre}${^exp#${pre}} )
   fi
   [[ $#exp -eq 1 && "$exp[1]" = "$word" ]] && return 1
 fi


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-08-07 15:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-07 14:58 PATCH: modifiers with _expand and keep-prefix Oliver Kiddle

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).