summary refs log tree commit diff
path: root/Test
diff options
context:
space:
mode:
Diffstat (limited to 'Test')
-rw-r--r--Test/X02zlevi.ztst20
-rw-r--r--Test/comptest33
2 files changed, 48 insertions, 5 deletions
diff --git a/Test/X02zlevi.ztst b/Test/X02zlevi.ztst
new file mode 100644
index 000000000..d4a125f21
--- /dev/null
+++ b/Test/X02zlevi.ztst
@@ -0,0 +1,20 @@
+# Tests of the vi mode of ZLE
+
+%prep
+  if ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
+    . $ZTST_srcdir/comptest
+    comptestinit -v -z $ZTST_testdir/../Src/zsh
+  else
+    ZTST_unimplemented="the zsh/zpty module is not available"
+  fi
+
+%test
+
+  zletest $'one two\ebmt3|`tx``'
+0:setting mark and returning to original position
+>BUFFER: one wo
+>CURSOR: 2
+
+%clean
+
+  zmodload -ui zsh/zpty
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]}"
+}