summaryrefslogtreecommitdiff
path: root/Test/comptest
diff options
context:
space:
mode:
Diffstat (limited to 'Test/comptest')
-rw-r--r--Test/comptest33
1 files changed, 28 insertions, 5 deletions
diff --git a/Test/comptest b/Test/comptest
index 14938a7cd..5577209da 100644
--- a/Test/comptest
+++ b/Test/comptest
@@ -8,10 +8,12 @@ comptestinit () {
zmodload -i zsh/zpty || return $?
comptest_zsh=${ZSH:-zsh}
+ comptest_keymap=e
- while getopts z: opt; do
+ while getopts vz: opt; do
case $opt in
z) comptest_zsh="$OPTARG";;
+ v) comptest_keymap="v";;
esac
done
(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
@@ -30,11 +32,11 @@ comptestinit () {
"export ZDOTDIR=$ZTST_testdir" \
"module_path=( $module_path )" \
"fpath=( $fpath )" \
+"bindkey -$comptest_keymap" \
'LISTMAX=10000000
TERM=vt100
stty columns 80 rows 24
setopt zle
-bindkey -e
autoload -U compinit
compinit -u
zstyle ":completion:*:default" list-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>"
@@ -60,18 +62,29 @@ list-choices-with-report () {
zle clear-screen
zle -R
}
-finish () {
+comp-finish () {
print "<WIDGET><finish>"
zle kill-whole-line
zle clear-screen
zle -R
}
+zle-finish () {
+ print -lr "<WIDGET><finish>" "BUFFER: $BUFFER" "CURSOR: $CURSOR"
+ (( region_active )) && print -lr "MARK: $MARK"
+ zle -K main
+ zle kill-whole-line
+ zle clear-screen
+ zle -R
+}
zle -N expand-or-complete-with-report
zle -N list-choices-with-report
-zle -N finish
+zle -N comp-finish
+zle -N zle-finish
bindkey "^I" expand-or-complete-with-report
bindkey "^D" list-choices-with-report
-bindkey "^Z" finish
+bindkey "^Z" comp-finish
+bindkey "^M" zle-finish
+bindkey -a "^M" zle-finish
'
}
@@ -120,3 +133,13 @@ comptest () {
done
done
}
+
+zletest () {
+ input="$*"
+ zpty -n -w zsh "$input"$'\C-M'
+ zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
+ print "failed to invoke finish widget."
+ return 1
+ }
+ print -lr "${(@)${(ps:\r\n:)log##*<WIDGET><finish>}[1,-2]}"
+}