about summary refs log tree commit diff
path: root/Test/X02zlevi.ztst
blob: d3b5334906eee42d9d31e81a80aa50214e7342d9 (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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
# Tests of the vi mode of ZLE

%prep
  if [[ $OSTYPE = cygwin ]]; then
    ZTST_unimplemented="the zsh/zpty module does not work on Cygwin"
  elif ( zmodload zsh/zpty 2>/dev/null ); 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

  zpty_run 'bindkey -r "\e~"'
  zletest $'\e' $'~aI\e' $'~o\e' \~
0:swap case on a blank line
>BUFFER: i
>
>CURSOR: 2

  zletest $'\eOword\eO\eraok\ejrxj.rae'
0:replace character when at end of buffer or newline
>BUFFER: ok
>wxrd
>e
>CURSOR: 9

  zletest $'two\eOone\ehRreplace'
0:replace acts like insert at newline
>BUFFER: oreplace
>two
>CURSOR: 8

  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 $'fi\eO\eOif\e2>j'
0:don't indent blank lines
>BUFFER: 	if
>
>	fi
>CURSOR: 1

  zletest $'\C-v\ti\e>>'
0:additional indentation
>BUFFER: 		i
>CURSOR: 2

  zletest $'one\eox\e>k'
0:indent with one character on final line
>BUFFER: 	one
>	x
>CURSOR: 1

  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 $'one two\e03rX$.'
0:repeat replace chars at the end of the line consumes the replace char
>BUFFER: XXX two
>CURSOR: 6

  zletest $'one two three\e02rxw3.w.'
0:numeric argument to repeat replaces change count
>BUFFER: xxe xxx xxxee
>CURSOR: 10

  zletest $'one two three four five six seven eight\e.03d2wk.1.'
0:numeric args to both action and movement are multiplied (and saved for any repeat)
>BUFFER: eight
>seven eight
>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 $'123456789\exxxxxxxxx"1P.........'
0:repeat advances to next killring register
>BUFFER: 9987654321
>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

  print -u $ZTST_fd 'This test may hang the shell when it fails...'
  zletest $'worm\erdhd..'
0:use of vi-repeat as the motion and repeat after a failed change
>BUFFER: wodd
>CURSOR: 2

  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

  zletest $'keepnot\eo  unwanted\ekhhcvj '
0:force character-wise change to join lines
>BUFFER: keep wanted
>CURSOR: 5

  zletest $'}\eOkeep{del\eF{dvj'
0:character-wise delete to beginning of line leaves the newline'
>BUFFER: keep
>}
>CURSOR: 3

  zletest $'keep\eOdel\edVh'
0:force line-wise delete of line
>BUFFER: keep
>CURSOR: 0

  zletest $'one two three\eFwdVawaX'
0:line-wise force of a text object
>BUFFER: X
>CURSOR: 1

  zletest $'one two\evbcx'
0:change selection
>BUFFER: one x
>CURSOR: 5

  zletest $'four\eOthree\eOtwo\eOone\evjjhCnew'
0:change character wise selection with C acts linewise
>BUFFER: new
>four
>CURSOR: 3

  zletest $'x testing\ehvbx'
0:x kills selections
>BUFFER: x g
>CURSOR: 2

  zletest $'line end\eOstart 1 back new\e0verawvrbwevbrcwvj0erdwv$re'
0:replace characters in selections
>BUFFER: aaaaa b cccc dddddddd eee
>CURSOR: 24

  zletest $'one two\eyb0vep'
0:put over selection at start of buffer
>BUFFER: tw two
>CURSOR: 1

  zletest $'hello\C-wbye\evhp'
0:put over selection at end of buffer
>BUFFER: bhello
>CURSOR: 5

  zletest $'old\C-w\evyvP'
0:yank empty selection
>BUFFER: old
>CURSOR: 2

  zletest $'old\C-w\evdvP'
0:delete empty selection
>BUFFER: old
>CURSOR: 2

  zletest $'one\eotwo\eyykVp'
0:yank linewise and put over linewise selection at start of buffer
>BUFFER: two
>two
>CURSOR: 0

  zletest $'one\eotwo\eothree\eyykVp'
0:yank linewise and put over linewise selection in middle of buffer
>BUFFER: one
>three
>three
>CURSOR: 4

  zletest $'two\eOone\eyyjVp'
0:yank linewise and put over linewise selection at end of buffer
>BUFFER: one
>one
>CURSOR: 4

  zletest $'one\eyhVp'
0:yank character-wise and put over linewise selection
>BUFFER: n
>CURSOR: 0

# vim puts a blank line above in this test
  zletest $'one\eotwo\eyy0kvlp'
0:yank linewise and put over character-wise selection at start of buffer
>BUFFER: two
>e
>two
>CURSOR: 0

  zletest $'one\eyyhvp'
0:yank linewise and put over character-wise selection in middle of buffer
>BUFFER: o
>one
>e
>CURSOR: 2

# vim behaviour on this one really looks like a bug
  zletest $'two\eOone\eyyjvhp'
0:yank linewise and put over character-wise selection at end of buffer
>BUFFER: one
>t
>one
>CURSOR: 6

  zletest $'abc123456789\exxxxxxxxxhv"9p0P'
0:paste last (9th) register over a selection
>BUFFER: ba9c
>CURSOR: 0

  zletest $'one\eo\eo\eotwo\ekkVdvd'
0:delete blank line using selection
>BUFFER: one
>two
>CURSOR: 4

  zletest $'One Two Three\e2bvw~'
0:toggle case of selection
>BUFFER: One tWO three
>CURSOR: 4

  zletest $' --ww  ww--\eo\eoww\eo\eo--\eo\eo  ww\e' bi{a,b,c,d,e,f,g,h,i,j,k}$'\e'
0:backward word
>BUFFER: k j--iww  hwwg--
>f
>eww
>d
>c--
>b
>  aww
>CURSOR: 0

  zletest $' --ww  ww--\eo\eoww\eo\eo--\eo\eo  ww\e' Bi{a,b,c,d,e,f,g,h,i}$'\e'
0:backword blank word
>BUFFER: i h--ww  gww--
>f
>eww
>d
>c--
>b
>  aww
>CURSOR: 0

  zletest $' --ww  ww--\eo\eoww\eo\eo--\eo\eo  ww\e' gei{a,=,b,c,=,d,e,=,f}$'\e'
0:backward word end
>BUFFER: f -=-wew  wdw-=-
>c
>wbw
>
>-=-
>a
>  ww
>CURSOR: 0

  zletest $' --ww  ww--\eo\eoww\eo\eo--\eo\eo  ww\e' gEi{=,b,=,d,e}$'\e'
0:backward blank word end
>BUFFER: e --wdw  ww-=-
>
>wbw
>
>-=-
>
>  ww
>CURSOR: 0

  zletest $'  ww\eO\eO--\eO\eOww\eO\eO --ww  ww--\e0' wi{=,a,b,=,c,d,e,=,f,g}$'\e'
0:forward word
>BUFFER:  =--aww  bww=--
>c
>dww
>e
>=--
>f
>  gww
>CURSOR: 32

  zletest $'  ww\eO\eO--\eO\eOww\eO\eO --ww  ww--\e0' Wi{=,a,b,c,d,=,e,f}$'\e'
0:forward blank word
>BUFFER:  =--ww  aww--
>b
>cww
>d
>=--
>e
>  fww
>CURSOR: 30

  zletest $'  ww\eO\eO--\eO\eOww\eO\eO --ww  ww--\e0' ea{a,b,c,d,e,f,g}$'\e'
0:forward word end
>BUFFER:  --awwb  wwc--d
>
>wwe
>
>--f
>
>  wwg
>CURSOR: 31

  zletest $'  ww\eO\eO--\eO\eOww\eO\eO --ww  ww--\e0' Ea{a,b,c,d,e}$'\e'
0:forward blank word end
>BUFFER:  --wwa  ww--b
>
>wwc
>
>--d
>
>  wwe
>CURSOR: 29

  zletest $'    ----word    ----    word    word----    ----\e42|daw30|daw22|daw14|daw2|daw'
0:delete all word on blanks
>BUFFER: word
>CURSOR: 0

  zletest $'    word----word    word----word    word    \e38|daw30|daw22|daw14|daw6|daw'
0:delete all word on alphanumerics
>BUFFER:     --------
>CURSOR: 4

  zletest $'    ----word----    ----word----    ----    \e38|daw30|daw22|daw14|daw6|daw'
0:delete all word on other characters
>BUFFER:     wordword
>CURSOR: 4

  zletest $'- word word\e4|2daw'
0:delete all word with numeric argument
>BUFFER: -
>CURSOR: 0

  zletest $'----    word    ----word\eo    \eo----\eodone\eh' \
      'vhawmaawmbawmcawmdawmeawmfawmgv`ara`brb`crc$r$`drd`ere`frf`grg'
0:all word with existing selection and cursor before mark
>BUFFER: g---f   worde   ----dord
>c  $
>b---
>aone
>CURSOR: 0

  zletest $'----    word    word----\e0lvlawmaawmbawmcawvrd`ara`brb`crc'
0:all word with existing selection and mark before cursor
>BUFFER: ----   aword   bworc---d
>CURSOR: 19

  zletest $' --ww  ww---\eo\eoww\evhiwiw' m{a,b,c,d,e}iw vrE \`{a,b,c,d,e}r.
0:in word with existing selection and cursor before mark
>BUFFER: E.-.w. .w.--
>
>ww
>CURSOR: 1

  zletest $'  --ww  ww--\eO  \ev0o' m{a,b,c,d,e}iw vrE \`{a,b,c,d,e}r.
0:in word with existing selection and mark before cursor
>BUFFER:  .
> .-.w. .wE--
>CURSOR: 10

  zletest $'  `one`  $(echo two) " three " $\'four\'\C-v\tfive ${six:-6}\e' \
      vaaom{a,b,c,d,e,f}v \`{a,b,c,d,e,f}rX
0:all argument for different arguments
>BUFFER: X `one`X $(echo two)X" three "X$'four'XfiveX${six:-6}
>CURSOR: 0

  zletest $'{ls `echo x`  $((3+4)) "a b" $\'\\t\\n\' ${d%/}\e' \
      cia{6,5,4,3,2,1}$'\eBB'
0:in argument for different arguments
>BUFFER: 1ls `2`  $(3) "4" $'5' ${6}
>CURSOR: 0

%clean

  zmodload -ui zsh/zpty