annotate src/testdir/test_undo.vim @ 10631:cbf17371627c v8.0.0205

patch 8.0.0205: wrong behavior after :undojoin commit https://github.com/vim/vim/commit/5e4e1b12998b1ed99138cad1c5da4d430f798547 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 17 22:09:45 2017 +0100 patch 8.0.0205: wrong behavior after :undojoin Problem: After :undojoin some commands don't work properly, such as :redo. (Matthew Malcomson) Solution: Don't set curbuf->b_u_curhead. (closes #1390)
author Christian Brabandt <cb@256bit.org>
date Tue, 17 Jan 2017 22:15:04 +0100
parents de77fa909414
children ae45d497868f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for the undo tree.
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " Since this script is sourced we need to explicitly break changes up in
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " undo-able pieces. Do that by setting 'undolevels'.
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 " Also tests :earlier and :later.
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 func Test_undotree()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 exe "normal Aabc\<Esc>"
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 set ul=100
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 exe "normal Adef\<Esc>"
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 set ul=100
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 undo
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 let d = undotree()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call assert_true(d.seq_last > 0)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 call assert_true(d.seq_cur > 0)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_true(d.seq_cur < d.seq_last)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call assert_true(len(d.entries) > 0)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 " TODO: check more members of d
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 w! Xtest
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call assert_equal(d.save_last + 1, undotree().save_last)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 call delete('Xtest')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 bwipe Xtest
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 endfunc
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 func FillBuffer()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 for i in range(1,13)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 put=i
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 " Set 'undolevels' to split undo.
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 exe "setg ul=" . &g:ul
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 endfor
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 endfunc
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 func Test_global_local_undolevels()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 new one
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 set undolevels=5
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 call FillBuffer()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 " will only undo the last 5 changes, end up with 13 - (5 + 1) = 7 lines
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 earlier 10
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 call assert_equal(5, &g:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 call assert_equal(-123456, &l:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 call assert_equal('7', getline('$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 new two
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 setlocal undolevels=2
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 call FillBuffer()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 " will only undo the last 2 changes, end up with 13 - (2 + 1) = 10 lines
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 earlier 10
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 call assert_equal(5, &g:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 call assert_equal(2, &l:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 call assert_equal('10', getline('$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 setlocal ul=10
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 call assert_equal(5, &g:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 call assert_equal(10, &l:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 " Setting local value in "two" must not change local value in "one"
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 wincmd p
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 call assert_equal(5, &g:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 call assert_equal(-123456, &l:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 new three
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 setglobal ul=50
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 call assert_equal(50, &g:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 call assert_equal(-123456, &l:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 " Drop created windows
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 set ul&
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 new
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 only!
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 endfunc
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 func BackOne(expected)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 call feedkeys('g-', 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 call assert_equal(a:expected, getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 endfunc
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 func Test_undo_del_chars()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 " Setup a buffer without creating undo entries
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 new
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 set ul=-1
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 call setline(1, ['123-456'])
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 set ul=100
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 1
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 call test_settime(100)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 " Delete three characters and undo with g-
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 call feedkeys('x', 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 call feedkeys('x', 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 call feedkeys('x', 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 call assert_equal('-456', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 call BackOne('3-456')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 call BackOne('23-456')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 call BackOne('123-456')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 call assert_fails("BackOne('123-456')")
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 :" Delete three other characters and go back in time with g-
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 call feedkeys('$x', 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 call feedkeys('x', 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 call feedkeys('x', 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100 call assert_equal('123-', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 call test_settime(101)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 call BackOne('123-4')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 call BackOne('123-45')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 " skips '123-456' because it's older
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 call BackOne('-456')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 call BackOne('3-456')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 call BackOne('23-456')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 call BackOne('123-456')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 call assert_fails("BackOne('123-456')")
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 normal 10g+
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 call assert_equal('123-', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 :" Jump two seconds and go some seconds forward and backward
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 call test_settime(103)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 call feedkeys("Aa\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 call feedkeys("Ab\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 call feedkeys("Ac\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 call assert_equal('123-abc', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 earlier 1s
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 call assert_equal('123-', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 earlier 3s
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 call assert_equal('123-456', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 later 1s
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 call assert_equal('123-', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 later 1h
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 call assert_equal('123-abc', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129 close!
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 endfunc
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131
10049
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
132 func Test_undolist()
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
133 new
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
134 set ul=100
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
135
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
136 let a=execute('undolist')
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
137 call assert_equal("\nNothing to undo", a)
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
138
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
139 " 1 leaf (2 changes).
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
140 call feedkeys('achange1', 'xt')
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
141 call feedkeys('achange2', 'xt')
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
142 let a=execute('undolist')
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
143 call assert_match("^\nnumber changes when *saved\n *2 *2 .*$", a)
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
144
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
145 " 2 leaves.
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
146 call feedkeys('u', 'xt')
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
147 call feedkeys('achange3\<Esc>', 'xt')
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
148 let a=execute('undolist')
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
149 call assert_match("^\nnumber changes when *saved\n *2 *2 *.*\n *3 *2 .*$", a)
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
150 close!
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
151 endfunc
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
152
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
153 func Test_U_command()
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
154 new
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
155 set ul=100
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
156 call feedkeys("achange1\<Esc>", 'xt')
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
157 call feedkeys("achange2\<Esc>", 'xt')
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
158 norm! U
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
159 call assert_equal('', getline(1))
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
160 norm! U
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
161 call assert_equal('change1change2', getline(1))
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
162 close!
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
163 endfunc
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
164
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 func Test_undojoin()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 new
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 call feedkeys("Goaaaa\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 call feedkeys("obbbb\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 call assert_equal(['aaaa', 'bbbb'], getline(2, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 call feedkeys("u", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 call assert_equal(['aaaa'], getline(2, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 call feedkeys("obbbb\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 undojoin
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 " Note: next change must not be as if typed
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 call feedkeys("occcc\<Esc>", 'x')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 call assert_equal(['aaaa', 'bbbb', 'cccc'], getline(2, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 call feedkeys("u", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 call assert_equal(['aaaa'], getline(2, '$'))
10631
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
179 bwipe!
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
180 endfunc
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
181
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
182 func Test_undojoin_redo()
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
183 new
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
184 call setline(1, ['first line', 'second line'])
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
185 call feedkeys("ixx\<Esc>", 'xt')
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
186 call feedkeys(":undojoin | redo\<CR>", 'xt')
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
187 call assert_equal('xxfirst line', getline(1))
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
188 call assert_equal('second line', getline(2))
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
189 bwipe!
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190 endfunc
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
192 func Test_undo_write()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 split Xtest
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194 call feedkeys("ione one one\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195 w!
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196 call feedkeys("otwo\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 call feedkeys("otwo\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198 w
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
199 call feedkeys("othree\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
200 call assert_equal(['one one one', 'two', 'two', 'three'], getline(1, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
201 earlier 1f
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
202 call assert_equal(['one one one', 'two', 'two'], getline(1, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203 earlier 1f
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
204 call assert_equal(['one one one'], getline(1, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
205 earlier 1f
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
206 call assert_equal([''], getline(1, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207 later 1f
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208 call assert_equal(['one one one'], getline(1, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209 later 1f
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 call assert_equal(['one one one', 'two', 'two'], getline(1, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 later 1f
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212 call assert_equal(['one one one', 'two', 'two', 'three'], getline(1, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214 close!
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 call delete('Xtest')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216 bwipe! Xtest
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 endfunc
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
218
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
219 func Test_insert_expr()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
220 new
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
221 " calling setline() triggers undo sync
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222 call feedkeys("oa\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 call feedkeys("ob\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224 set ul=100
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225 call feedkeys("o1\<Esc>a2\<C-R>=setline('.','1234')\<CR>\<CR>\<Esc>", 'x')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226 call assert_equal(['a', 'b', '120', '34'], getline(2, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
227 call feedkeys("u", 'x')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
228 call assert_equal(['a', 'b', '12'], getline(2, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
229 call feedkeys("u", 'x')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
230 call assert_equal(['a', 'b'], getline(2, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232 call feedkeys("oc\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233 set ul=100
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
234 call feedkeys("o1\<Esc>a2\<C-R>=setline('.','1234')\<CR>\<CR>\<Esc>", 'x')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
235 call assert_equal(['a', 'b', 'c', '120', '34'], getline(2, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236 call feedkeys("u", 'x')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
237 call assert_equal(['a', 'b', 'c', '12'], getline(2, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
238
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239 call feedkeys("od\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
240 set ul=100
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241 call feedkeys("o1\<Esc>a2\<C-R>=string(123)\<CR>\<Esc>", 'x')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
242 call assert_equal(['a', 'b', 'c', '12', 'd', '12123'], getline(2, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
243 call feedkeys("u", 'x')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
244 call assert_equal(['a', 'b', 'c', '12', 'd'], getline(2, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
245
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
246 close!
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
247 endfunc
10518
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
248
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
249 func Test_undofile_earlier()
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
250 " Issue #1254
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
251 " create undofile with timestamps older than Vim startup time.
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
252 let t0 = localtime() - 43200
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
253 call test_settime(t0)
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
254 new Xfile
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
255 call feedkeys("ione\<Esc>", 'xt')
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
256 set ul=100
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
257 call test_settime(t0 + 1)
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
258 call feedkeys("otwo\<Esc>", 'xt')
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
259 set ul=100
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
260 call test_settime(t0 + 2)
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
261 call feedkeys("othree\<Esc>", 'xt')
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
262 set ul=100
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
263 w
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
264 wundo Xundofile
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
265 bwipe!
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
266 " restore normal timestamps.
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
267 call test_settime(0)
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
268 new Xfile
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
269 rundo Xundofile
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
270 earlier 1d
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
271 call assert_equal('', getline(1))
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
272 bwipe!
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
273 call delete('Xfile')
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
274 call delete('Xundofile')
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
275 endfunc