view src/testdir/test61.in @ 2214:f8222d1f9a73 vim73

Included patch for persistent undo. Lots of changes and added test.
author Bram Moolenaar <bram@vim.org>
date Sun, 23 May 2010 23:34:36 +0200
parents 2c885fab04e3
children 2e6906bbc5f4
line wrap: on
line source

Tests for undo tree.
Since this script is sourced we need to explicitly break changes up in
undo-able pieces.  Do that by setting 'undolevels'.

STARTTEST
:" Delete three characters and undo
Gx:set ul=100
x:set ul=100
x:.w! test.out
g-:.w >>test.out
g-:.w >>test.out
g-:.w >>test.out
g-:.w >>test.out
:"
:/^111/w >>test.out
:" Delete three other characters and go back in time step by step
$x:set ul=100
x:set ul=100
x:.w >>test.out
:sleep 1
g-:.w >>test.out
g-:.w >>test.out
g-:.w >>test.out
g-:.w >>test.out
g-:.w >>test.out
g-:.w >>test.out
g-:.w >>test.out
g-:.w >>test.out
10g+:.w >>test.out
:"
:/^222/w >>test.out
:" Delay for three seconds and go some seconds forward and backward
:sleep 2
Aa:set ul=100
Ab:set ul=100
Ac:set ul=100
:.w >>test.out
:ear 1s
:.w >>test.out
:ear 3s
:.w >>test.out
:later 1s
:.w >>test.out
:later 1h
:.w >>test.out
:"
:" test undojoin
Goaaaa:set ul=100
obbbbu:.w >>test.out
obbbb:set ul=100
:undojoin
occccu:.w >>test.out
:"
:" Test 'undofile': first a simple one-line change.
:set nocp ul=100 undofile
:e! Xtestfile
ggdGithis is one line:set ul=100
:s/one/ONE/
:set ul=100
:w
:bwipe!
:e Xtestfile
u:.w >>test.out
:"
:" Test 'undofile', change in original file fails check
:set noundofile
:e! Xtestfile
:s/line/Line/
:w
:set undofile
:bwipe!
:e Xtestfile
u:.w >>test.out
:"
:" Test 'undofile', add 10 lines, delete 6 lines, undo 3
:set undofile
ggdGione
two
three
four
five
six
seven
eight
nine
ten:set ul=100
3Gdd:set ul=100
dd:set ul=100
dd:set ul=100
dd:set ul=100
dd:set ul=100
dd:set ul=100
:w
:bwipe!
:e Xtestfile
uuu:w >>test.out
:"
:" Rename the undo file so that it gets cleaned up.
:call rename(".Xtestfile.un~", "Xtestundo")
:qa!
ENDTEST

1111 -----
2222 -----

123456789