summary refs log tree commit diff
path: root/Test/X02zlevi.ztst
blob: 4b9c4d91fb58fec5388707349f009bae10688d2f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# 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 $'goox\ecld'
0:change last character in buffer
>BUFFER: good
>CURSOR: 4

  zletest $'{ ({[}]) }\e0c%chg'
0:change forward to matching bracket
>BUFFER: chg
>CURSOR: 3

  zletest $'s( match )\ed%'
0:delete backwards to matching bracket
>BUFFER: s
>CURSOR: 0

  zletest $'one\eo\edd'
0:delete empty line
>BUFFER: one
>CURSOR: 0

  zletest $'1\eo\eyya2\epa3'
0:yank and paste blank line
>BUFFER: 1
>2
>3
>CURSOR: 5

  zletest $' four\eO\C-v\tthree\eO  two\eOone\e3J'
0:join lines with line count
>BUFFER: one two three
> four
>CURSOR: 7

# like real vi, we just join as many as possible, in vim this beeps
  zletest $'two\eOone\e3J'
0:join more lines than possible
>BUFFER: one two
>CURSOR: 3

  zletest $'one two\eyb'
0:yank left moves the cursor
>BUFFER: one two
>CURSOR: 4

  zletest $'one two\e0ye'
0:yank right leaves the cursor
>BUFFER: one two
>CURSOR: 0

  zletest $'short\eoand longer\eyk'
0:yank up line moves cursor up but not to buffer start
>BUFFER: short
>and longer
>CURSOR: 4

  zletest $'one\eotwo\ekyj'
0:yank down line leaves the cursor
>BUFFER: one
>two
>CURSOR: 2

  zletest $'long\eo  s\eolong\ekjy-k'
0:yank up clears lastcol
>BUFFER: long
>  s
>long
>CURSOR: 2

  zletest $'long\eos\eklljyk'
0:yank up honours lastcol
>BUFFER: long
>s
>CURSOR: 2

  zletest $'long\eolong\eo  s\eolong\ekjd-k'
0:delete up clears lastcol
>BUFFER: long
>long
>CURSOR: 0

  zletest $'yankee doodle\ebhDyy0"1P'
0:paste register 1 to get last deletion
>BUFFER:  doodleyankee
>CURSOR: 6

  zletest $'yankee\eyyodoodle\edd"0p'
0:paste register 0 to get last yank
>BUFFER: yankee
>yankee
>CURSOR: 7

  zletest $'err\eddahello\e"hddP'
0:setting named register also sets unnamed register
>BUFFER: hello
>CURSOR: 0

  zletest $'first\e"ay0ddasecond\e"Add"aP'
0:appending to named register
>BUFFER: firs
>second
>CURSOR: 0

  zletest $'word\e"a"byy"bp'
0:set one and then a different register
>BUFFER: word
>word
>CURSOR: 5

  zletest $'i\exaar\e0"a"_cewn\eP'
0:set register then set black hole register
>BUFFER: win
>CURSOR: 1

  zletest $'double\eyy"_"0P'
0:reset register after selecting black hole
>BUFFER: double
>double
>CURSOR: 0

# zsh works like vi here; in vim you get the concatenated string
  zletest $'first\e"addasecond\eddP'
0:retrieve unnamed register after appending
>BUFFER: second
>CURSOR: 0

  zletest $'Z\exayankee doodle\e"_db0"_yeP'
0:yank and delete to black hole register
>BUFFER: Zyankee e
>CURSOR: 0

  zletest $'foo\eddabar\e"_p..'
0:paste from black hole register and repeat
>BUFFER: bar
>CURSOR: 2

  zletest $'start\eFa"ac2lnew\eX"ap..'
0:repeat paste from named register
>BUFFER: stnwararart
>CURSOR: 9

  zpty_run 'bindkey -a "^P" yank-pop'
  zletest $'word\C-wline\eddiSE\eP\C-P'
0:line based put before followed by character based yank-pop
>BUFFER: SwordE
>CURSOR: 4

  zletest $'line\eddiword\C-w\eiSE\eP\C-P'
0:character based put before followed by line based yank-pop
>BUFFER: line
>SE
>CURSOR: 0

  zletest $'one two three\C-w\C-w\C-wSE\e0p\C-P\C-P'
0:put after cycled twice with yank-pop
>BUFFER: SthreeE
>CURSOR: 5

  zletest $'word\C-wline\eddiSE\ehp\C-P'
0:line based put after followed by character based yank-pop
>BUFFER: SwordE
>CURSOR: 4

  zletest $'line\eddiword\C-w\eiSE\ehp\C-P'
0:character based after before followed by line based yank-pop
>BUFFER: SE
>line
>CURSOR: 3

  zletest $'word\euaend'
0:undo initial change
>BUFFER: end
>CURSOR: 3

  zletest $'text\e.'
0:repeat initial edit
>BUFFER: text
>text
>CURSOR: 8

  zpty_run 'print -z before'
  zletest $'after\e.'
0:repeat initial edit with non-blank starting line
>BUFFER: beforeafterafter
>CURSOR: 15

  zpty_run 'setopt overstrike;print -z bung'
  zletest $'ing\e2|.'
0:repeat initial edit with overstrike set
>BUFFER: binging
>CURSOR: 3

  zpty_run 'bindkey "^_" undo'
  zletest $'undoc\037e'
0:use of undo in vi insert mode
>BUFFER: undoe
>CURSOR: 5

  zletest $'one\euatwo\e0clthree'
0:vi mode undo of initial and subsequent change
>BUFFER: threewo
>CURSOR: 5

  zletest $'xxx\euiyyy\euAz'
0:undo invoked twice
>BUFFER: z
>CURSOR: 1

  zpty_run 'bindkey -a "^K" redo'
  zletest $'123\C-_\e\C-k'
0:undo in insert mode, redo in command
>BUFFER: 123
>CURSOR: 2

  zpty_run 'bindkey "^Y" redo'
  zletest $'pre\eA123\C-_\C-y\eu'
0:undo and redo in insert mode, undo in command
>BUFFER: pre
>CURSOR: 2

  zletest $'two\eOone\eo\euo\eu'
0:undo starting with a next change in the change list
>BUFFER: one
>two
>CURSOR: 2

  zpty_run 'bindkey "^Gu" split-undo'
  zletest $'one\C-gutwo\eu'
0:split the undo sequence
>BUFFER: one
>CURSOR: 2

  zletest $'one two\ebmt3|`tx``'
0:setting mark and returning to original position
>BUFFER: one wo
>CURSOR: 2

%clean

  zmodload -ui zsh/zpty