zsh-workers
 help / color / mirror / code / Atom feed
* [BUG+PATCH] Let _expand preserve array form w/out zstyle glob
@ 2021-11-12 19:56 Marlon Richert
  0 siblings, 0 replies; only message in thread
From: Marlon Richert @ 2021-11-12 19:56 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 237 bytes --]

This is the bug:

% autoload compinit; compinit
% typeset -g tst=(a b)
% : $tst^D
expansions
a  b
% zstyle '*' glob no
% : $tst
expansions
a\ b

I would expect the output to be the same, since we're not globbing here.

Below is the fix.

[-- Attachment #2: 0001-Let-_expand-preserve-array-form-w-out-zstyle-glob.txt --]
[-- Type: text/plain, Size: 1575 bytes --]

From d92ac7a8708cdb31e1a9cc5e7430558414233f19 Mon Sep 17 00:00:00 2001
From: Marlon Richert <marlonrichert@users.noreply.github.com>
Date: Fri, 12 Nov 2021 21:52:18 +0200
Subject: [PATCH] Let _expand preserve array form w/out zstyle glob

---
 Completion/Base/Completer/_expand |  2 +-
 Test/Y01completion.ztst           | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/Completion/Base/Completer/_expand b/Completion/Base/Completer/_expand
index 86b4ac6e4..e5e4f9b39 100644
--- a/Completion/Base/Completer/_expand
+++ b/Completion/Base/Completer/_expand
@@ -105,7 +105,7 @@ subd=("$exp[@]")
 
 # We need to come out of this with consistent quoting, by hook or by crook.
 integer done_quote
-local orig_exp=$exp
+local -a orig_exp=( $exp )
 if [[ "$force" = *g* ]] || zstyle -T ":completion:${curcontext}:" glob; then
   eval 'exp=( ${~exp//(#b)\\([ 	\"'"\'"'
 ])/$match[1]} ); exp=( ${(q)exp} )' 2>/dev/null && (( $#exp )) && done_quote=1
diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst
index 882a0adc4..6af0efc6d 100644
--- a/Test/Y01completion.ztst
+++ b/Test/Y01completion.ztst
@@ -62,6 +62,17 @@
 >line: {: dir1 dir2 file1 file2 }{}
 >line: {: *}{}
 
+  comptesteval $'zstyle \'*\' glob no'
+  comptesteval $'typeset -g tst=(*)'
+  comptest $': $tst\C-D'
+0:_expand preserves array form
+>DESCRIPTION:{expansions}
+>NO:{dir1}
+>NO:{dir2}
+>NO:{file1}
+>NO:{file2}
+
+  comptesteval $'zstyle -d \'*\' glob'
   comptesteval '_users () { compadd user1 user2 }'
   comptest $': ~\t\t\t\t\t'
 0:tilde
-- 
2.30.1 (Apple Git-130)


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

only message in thread, other threads:[~2021-11-12 19:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-12 19:56 [BUG+PATCH] Let _expand preserve array form w/out zstyle glob Marlon Richert

Code repositories for project(s) associated with this 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).