about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-02-29 15:51:18 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-02-29 15:51:18 +0000
commit7cc67a8a3702af11f7cda5fc18e19f8c75fffd54 (patch)
tree57221ec5e537fa644d17b433d17743a1065019c5
parentab215f232b0b1b69999d57f4a0f1da5816581b4f (diff)
downloadzsh-7cc67a8a3702af11f7cda5fc18e19f8c75fffd54.tar.gz
zsh-7cc67a8a3702af11f7cda5fc18e19f8c75fffd54.tar.xz
zsh-7cc67a8a3702af11f7cda5fc18e19f8c75fffd54.zip
zsh-workers/9936
-rw-r--r--Src/Zle/complist.c2
-rw-r--r--Test/53completion.ztst136
-rw-r--r--Test/comptest94
3 files changed, 231 insertions, 1 deletions
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 5a24c0e26..24dce4aff 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -745,7 +745,7 @@ clprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width,
 	}
 	zcoff();
 	if (!lastc) {
-	    zcputs(&mcolors, g->name, COL_NO);
+	    zcputs(&mcolors, g->name, COL_SP);
 	    fputs("  ", shout);
 	    zcoff();
 	}
diff --git a/Test/53completion.ztst b/Test/53completion.ztst
new file mode 100644
index 000000000..00f1c9218
--- /dev/null
+++ b/Test/53completion.ztst
@@ -0,0 +1,136 @@
+# Tests for completion system.
+
+%prep
+
+  comptest () { $ZTST_testdir/../Src/zsh -f $ZTST_srcdir/comptest -z $ZTST_testdir/../Src/zsh -d $ZTST_testdir/compdump.tmp "$@" }
+
+  mkdir comp.tmp
+  cd comp.tmp
+
+  mkdir dir1
+  mkdir dir2
+  touch file1
+  touch file2
+
+%test
+
+  comptest $': \t\t\t\t\t\t\t'
+0:directories and files
+>line: {: }{}
+>DESCRIPTION:{file}
+>DI:{dir1}
+>DI:{dir2}
+>FI:{file1}
+>FI:{file2}
+>line: {: dir1/}{}
+>line: {: dir2/}{}
+>line: {: file1}{}
+>line: {: file2}{}
+>line: {: dir1/}{}
+>line: {: dir2/}{}
+
+  comptest -c '_users () { compadd user1 user2 }' $': ~\t\t\t\t\t'
+0:tilde
+>line: {: ~user}{}
+>line: {: ~user}{}
+>NO:{user1}
+>NO:{user2}
+>line: {: ~user1}{}
+>line: {: ~user2}{}
+>line: {: ~user1}{}
+
+ code='compdef _tst tst; _tst () { _arguments ":desc1:(arg1)" }'
+ comptest -c "$code" $'tst \t'
+0:_arguments
+>line: {tst arg1 }{}
+
+ comptest -c "$code" $'tst a\t'
+0:_arguments
+>line: {tst arg1 }{}
+
+ comptest -c "$code" $'tst ar\t'
+0:_arguments
+>line: {tst arg1 }{}
+
+ comptest -c "$code" $'tst arg\t'
+0:_arguments
+>line: {tst arg1 }{}
+
+ comptest -c "$code" $'tst arg1\t'
+0:_arguments
+>line: {tst arg1 }{}
+
+ comptest -c "$code" $'tst r\t'
+0:_arguments
+>line: {tst r}{}
+
+ comptest -c "$code" $'tst x\t'
+0:_arguments
+>line: {tst x}{}
+
+ comptest -c "$code" $'tst a \t'
+0:_arguments
+>line: {tst a }{}
+>MESSAGE:{no more arguments}
+
+ comptest -c "$code" $'tst a b \t'
+0:_arguments
+>line: {tst a b }{}
+>MESSAGE:{no more arguments}
+
+ code='compdef _tst tst; _tst () { _arguments ":desc1:(a b)" }'
+ comptest -c "$code" $'tst \t'
+0:_arguments
+>line: {tst }{}
+>DESCRIPTION:{desc1}
+>NO:{a}
+>NO:{b}
+
+ code='compdef _tst tst; _tst () { _arguments ":desc1:(arg1)" ":desc2:(arg2)" ":desc3:(arg3)" }'
+ comptest -c "$code" $'tst \t'
+0:_arguments
+>line: {tst arg1 }{}
+
+ comptest -c "$code" $'tst arg1 \t'
+0:_arguments
+>line: {tst arg1 arg2 }{}
+
+ comptest -c "$code" $'tst arg1 arg2 \t'
+0:_arguments
+>line: {tst arg1 arg2 arg3 }{}
+
+ comptest -c "$code" $'tst \C-D'
+0:_arguments
+>DESCRIPTION:{desc1}
+>NO:{arg1}
+
+# code='compdef _tst tst; _tst () { _arguments "-\+[opt]" }'
+# comptest -c "$code" $'tst -\C-D'
+#0:_arguments
+#>DESCRIPTION:{option}
+#>NO:{-+ -- opt}
+
+ code='compdef _tst tst; _tst () { _arguments "1:desc1:(arg1)" }'
+ comptest -c "$code" $'tst \t'
+0:_arguments
+>line: {tst arg1 }{}
+
+ code='compdef _tst tst; _tst () { _arguments "-x" ":arg:" }'
+ comptest -c "$code" $'tst -\t'
+0:_arguments
+>line: {tst -x }{}
+
+ code='compdef _tst tst; _tst () { _arguments "-x:arg:" }'
+ comptest -c "$code" $'tst -x\t'
+0:_arguments
+>line: {tst -x }{}
+
+ code='
+   compdef _tst tst
+   _tst () { _arguments "-a" "*::rest:_tst2" }
+   _tst2 () { compadd - -b }
+ '
+ comptest -c "$code" $'tst arg -\t'
+0:_arguments
+>line: {tst arg -b }{}
+
diff --git a/Test/comptest b/Test/comptest
new file mode 100644
index 000000000..aae996105
--- /dev/null
+++ b/Test/comptest
@@ -0,0 +1,94 @@
+#!/usr/local/bin/zsh -f
+
+zmodload zsh/zpty
+setopt extendedglob
+
+debug=
+dump=(-D)
+code=
+zsh=${ZSH:-zsh}
+
+while getopts Dd:c:z: opt; do
+  case $opt in
+    D) debug=yes;;
+    d) dump=(-d "$OPTARG");;
+    c) code="$OPTARG";;
+    z) zsh="$OPTARG";;
+  esac
+done
+(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
+
+input="$*"
+
+init=\
+'stty columns 80 rows 24
+LISTMAX=10000000
+'"ZLS_COLORS='no=<NO>:fi=<FI>:di=<DI>:ln=<LN>:pi=<PI>:so=<SO>:bd=<BD>:cd=<CD>:ex=<EX>:mi=<MI>:tc=<TC>:sp=<SP>:lc=<LC>:ec=<EC>\n:rc=<RC>'
+bindkey -e
+autoload -U compinit
+compinit $dump
+"'zstyle ":completion:*" group-name ""
+zstyle ":completion*:messages" format "<MESSAGE>%d</MESSAGE>
+"
+zstyle ":completion*:descriptions" format "<DESCRIPTION>%d</DESCRIPTION>
+"
+zstyle ":completion*:options" verbose yes
+zstyle ":completion*:values" verbose yes
+setopt noalwayslastprompt listrowsfirst completeinword
+zmodload zsh/complist
+expand-or-complete-with-report () {
+  print -lr "<WIDGET><expand-or-complete>"
+  zle expand-or-complete
+  print -lr - "<LBUFFER>$LBUFFER</LBUFFER>" "<RBUFFER>$RBUFFER</RBUFFER>"
+  zle clear-screen
+  zle -R
+}
+list-choices-with-report () {
+  print -lr "<WIDGET><list-choices>"
+  zle list-choices
+  zle clear-screen
+  zle -R
+}
+finish () {
+  print "<WIDGET><finish>"
+  exit 0
+}
+zle -N expand-or-complete-with-report
+zle -N list-choices-with-report
+zle -N finish
+bindkey "^I" expand-or-complete-with-report
+bindkey "^D" list-choices-with-report
+bindkey "^Z" finish
+'"$code"
+
+export PS1="<PROMPT>"
+zpty zsh "$zsh" -f
+
+zpty -r zsh log "*<PROMPT>*"
+
+zpty -w zsh "eval ${init:q}"
+zpty -r zsh log "*<PROMPT>*"
+
+zpty -w zsh "$input"$'\C-Z'
+zpty -r zsh log "*<WIDGET><finish>*"
+
+logs=(${(s:<WIDGET>:)log})
+shift logs
+
+for log in "$logs[@]"; do
+  if [[ "$log" = (#b)*$'<LBUFFER>'(*)$'</LBUFFER>\r\n<RBUFFER>'(*)$'</RBUFFER>'* ]]; then
+    print -lr "line: {$match[1]}{$match[2]}"
+  fi
+  while (( ${(N)log#*(#b)(<LC><(??)><RC>(*)<EC>|<DESCRIPTION>(*)</DESCRIPTION>|<MESSAGE>(*)</MESSAGE>)} )); do
+    log="${log[$mend[1]+1,-1]}"
+    if (( 0 <= $mbegin[2] )); then
+      if [[ $match[2] != TC && $match[3] != \ # ]]; then
+	print "$match[2]:{$match[3]}"
+      fi
+    elif (( 0 <= $mbegin[4] )); then
+      print "DESCRIPTION:{$match[4]}"
+    elif (( 0 <= $mbegin[5] )); then
+      print "MESSAGE:{$match[5]}"
+    fi
+  done
+done