annotate src/testdir/test_undo.vim @ 33171:db2e9816e400 v9.0.1866

patch 9.0.1866: undo is synced after character find Commit: https://github.com/vim/vim/commit/dccc29c228f8336ef7dd069a447886639af4458e Author: zeertzjq <zeertzjq@outlook.com> Date: Mon Sep 4 22:25:07 2023 +0200 patch 9.0.1866: undo is synced after character find Problem: Undo is synced after character find. Solution: Set no_u_sync when calling gotchars_nop(). closes: #13022 closes: #13024 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
author Christian Brabandt <cb@256bit.org>
date Mon, 04 Sep 2023 22:30:07 +0200
parents b80d18055370
children 9590b7cf5a51
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
31406
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
6 source check.vim
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
7 source screendump.vim
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
8
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 func Test_undotree()
12827
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
10 new
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
11
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
12 normal! Aabc
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 set ul=100
12827
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
14 let d = undotree()
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
15 call assert_equal(1, d.seq_last)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
16 call assert_equal(1, d.seq_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
17 call assert_equal(0, d.save_last)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
18 call assert_equal(0, d.save_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
19 call assert_equal(1, len(d.entries))
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
20 call assert_equal(1, d.entries[0].newhead)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
21 call assert_equal(1, d.entries[0].seq)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
22 call assert_true(d.entries[0].time <= d.time_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
23
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
24 normal! Adef
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 set ul=100
12827
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
26 let d = undotree()
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
27 call assert_equal(2, d.seq_last)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
28 call assert_equal(2, d.seq_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
29 call assert_equal(0, d.save_last)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
30 call assert_equal(0, d.save_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
31 call assert_equal(2, len(d.entries))
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
32 call assert_equal(1, d.entries[0].seq)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
33 call assert_equal(1, d.entries[1].newhead)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
34 call assert_equal(2, d.entries[1].seq)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
35 call assert_true(d.entries[1].time <= d.time_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
36
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 undo
12827
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
38 set ul=100
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 let d = undotree()
12827
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
40 call assert_equal(2, d.seq_last)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
41 call assert_equal(1, d.seq_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
42 call assert_equal(0, d.save_last)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
43 call assert_equal(0, d.save_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
44 call assert_equal(2, len(d.entries))
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
45 call assert_equal(1, d.entries[0].seq)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
46 call assert_equal(1, d.entries[1].curhead)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
47 call assert_equal(1, d.entries[1].newhead)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
48 call assert_equal(2, d.entries[1].seq)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
49 call assert_true(d.entries[1].time == d.time_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
50
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
51 normal! Aghi
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
52 set ul=100
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
53 let d = undotree()
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
54 call assert_equal(3, d.seq_last)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
55 call assert_equal(3, d.seq_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
56 call assert_equal(0, d.save_last)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
57 call assert_equal(0, d.save_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
58 call assert_equal(2, len(d.entries))
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
59 call assert_equal(1, d.entries[0].seq)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
60 call assert_equal(2, d.entries[1].alt[0].seq)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
61 call assert_equal(1, d.entries[1].newhead)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
62 call assert_equal(3, d.entries[1].seq)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
63 call assert_true(d.entries[1].time <= d.time_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
64
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
65 undo
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
66 set ul=100
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
67 let d = undotree()
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
68 call assert_equal(3, d.seq_last)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
69 call assert_equal(1, d.seq_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
70 call assert_equal(0, d.save_last)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
71 call assert_equal(0, d.save_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
72 call assert_equal(2, len(d.entries))
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
73 call assert_equal(1, d.entries[0].seq)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
74 call assert_equal(2, d.entries[1].alt[0].seq)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
75 call assert_equal(1, d.entries[1].curhead)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
76 call assert_equal(1, d.entries[1].newhead)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
77 call assert_equal(3, d.entries[1].seq)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
78 call assert_true(d.entries[1].time == d.time_cur)
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 w! Xtest
12827
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
81 let d = undotree()
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
82 call assert_equal(1, d.save_cur)
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
83 call assert_equal(1, d.save_last)
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 call delete('Xtest')
12827
ff494a964ab7 patch 8.0.1290: seq_cur of undotree() wrong after undo
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
85 bwipe! Xtest
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 endfunc
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 func FillBuffer()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 for i in range(1,13)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 put=i
14015
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
91 " Set 'undolevels' to split undo.
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 exe "setg ul=" . &g:ul
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 endfor
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 endfunc
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95
32732
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
96 func Test_undotree_bufnr()
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
97 new
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
98 let buf1 = bufnr()
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
99
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
100 normal! Aabc
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
101 set ul=100
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
102
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
103 " Save undo tree without bufnr as ground truth for buffer 1
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
104 let d1 = undotree()
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
105
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
106 new
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
107 let buf2 = bufnr()
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
108
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
109 normal! Adef
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
110 set ul=100
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
111
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
112 normal! Aghi
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
113 set ul=100
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
114
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
115 " Save undo tree without bufnr as ground truth for buffer 2
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
116 let d2 = undotree()
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
117
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
118 " Check undotree() with bufnr argument
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
119 let d = undotree(buf1)
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
120 call assert_equal(d1, d)
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
121 call assert_notequal(d2, d)
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
122
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
123 let d = undotree(buf2)
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
124 call assert_notequal(d1, d)
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
125 call assert_equal(d2, d)
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
126
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
127 " Switch buffers and check again
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
128 wincmd p
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
129
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
130 let d = undotree(buf1)
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
131 call assert_equal(d1, d)
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
132
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
133 let d = undotree(buf2)
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
134 call assert_notequal(d1, d)
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
135 call assert_equal(d2, d)
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
136
32909
b80d18055370 patch 9.0.1763: crash when passing invalid buffer to undotree()
Christian Brabandt <cb@256bit.org>
parents: 32732
diff changeset
137 " error cases
b80d18055370 patch 9.0.1763: crash when passing invalid buffer to undotree()
Christian Brabandt <cb@256bit.org>
parents: 32732
diff changeset
138 call assert_fails('call undotree(-1)', 'E158:')
b80d18055370 patch 9.0.1763: crash when passing invalid buffer to undotree()
Christian Brabandt <cb@256bit.org>
parents: 32732
diff changeset
139 call assert_fails('call undotree("nosuchbuf")', 'E158:')
b80d18055370 patch 9.0.1763: crash when passing invalid buffer to undotree()
Christian Brabandt <cb@256bit.org>
parents: 32732
diff changeset
140
b80d18055370 patch 9.0.1763: crash when passing invalid buffer to undotree()
Christian Brabandt <cb@256bit.org>
parents: 32732
diff changeset
141 " after creating a buffer nosuchbuf, undotree('nosuchbuf') should
b80d18055370 patch 9.0.1763: crash when passing invalid buffer to undotree()
Christian Brabandt <cb@256bit.org>
parents: 32732
diff changeset
142 " not error out
b80d18055370 patch 9.0.1763: crash when passing invalid buffer to undotree()
Christian Brabandt <cb@256bit.org>
parents: 32732
diff changeset
143 new nosuchbuf
b80d18055370 patch 9.0.1763: crash when passing invalid buffer to undotree()
Christian Brabandt <cb@256bit.org>
parents: 32732
diff changeset
144 let d = {'seq_last': 0, 'entries': [], 'time_cur': 0, 'save_last': 0, 'synced': 1, 'save_cur': 0, 'seq_cur': 0}
b80d18055370 patch 9.0.1763: crash when passing invalid buffer to undotree()
Christian Brabandt <cb@256bit.org>
parents: 32732
diff changeset
145 call assert_equal(d, undotree("nosuchbuf"))
b80d18055370 patch 9.0.1763: crash when passing invalid buffer to undotree()
Christian Brabandt <cb@256bit.org>
parents: 32732
diff changeset
146 " clean up
b80d18055370 patch 9.0.1763: crash when passing invalid buffer to undotree()
Christian Brabandt <cb@256bit.org>
parents: 32732
diff changeset
147 bw nosuchbuf
b80d18055370 patch 9.0.1763: crash when passing invalid buffer to undotree()
Christian Brabandt <cb@256bit.org>
parents: 32732
diff changeset
148
32732
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
149 " Drop created windows
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
150 set ul&
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
151 new
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
152 only!
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
153 endfunc
257ab4ee8e4a patch 9.0.1686: undotree() only works for the current buffer
Christian Brabandt <cb@256bit.org>
parents: 31406
diff changeset
154
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 func Test_global_local_undolevels()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 new one
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 set undolevels=5
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 call FillBuffer()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 " 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
160 earlier 10
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 call assert_equal(5, &g:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 call assert_equal(-123456, &l:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 call assert_equal('7', getline('$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 new two
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 setlocal undolevels=2
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 call FillBuffer()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 " 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
169 earlier 10
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 call assert_equal(5, &g:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 call assert_equal(2, &l:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 call assert_equal('10', getline('$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 setlocal ul=10
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 call assert_equal(5, &g:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 call assert_equal(10, &l:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 " 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
179 wincmd p
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 call assert_equal(5, &g:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 call assert_equal(-123456, &l:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 new three
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 setglobal ul=50
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 call assert_equal(50, &g:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 call assert_equal(-123456, &l:undolevels)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187
19991
f27473034f26 patch 8.2.0551: not all code for options is tested
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
188 " Resetting the local 'undolevels' value to use the global value
f27473034f26 patch 8.2.0551: not all code for options is tested
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
189 setlocal undolevels=5
f27473034f26 patch 8.2.0551: not all code for options is tested
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
190 setlocal undolevels<
f27473034f26 patch 8.2.0551: not all code for options is tested
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
191 call assert_equal(-123456, &l:undolevels)
f27473034f26 patch 8.2.0551: not all code for options is tested
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
192
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 " Drop created windows
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194 set ul&
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195 new
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196 only!
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 endfunc
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
199 func BackOne(expected)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
200 call feedkeys('g-', 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
201 call assert_equal(a:expected, getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
202 endfunc
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
204 func Test_undo_del_chars()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
205 " Setup a buffer without creating undo entries
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
206 new
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207 set ul=-1
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208 call setline(1, ['123-456'])
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209 set ul=100
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 1
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 call test_settime(100)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213 " Delete three characters and undo with g-
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214 call feedkeys('x', 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 call feedkeys('x', 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216 call feedkeys('x', 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 call assert_equal('-456', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
218 call BackOne('3-456')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
219 call BackOne('23-456')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
220 call BackOne('123-456')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
221 call assert_fails("BackOne('123-456')")
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 :" 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
224 call feedkeys('$x', 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225 call feedkeys('x', 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226 call feedkeys('x', 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
227 call assert_equal('123-', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
228 call test_settime(101)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
229
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
230 call BackOne('123-4')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231 call BackOne('123-45')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232 " skips '123-456' because it's older
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233 call BackOne('-456')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
234 call BackOne('3-456')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
235 call BackOne('23-456')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236 call BackOne('123-456')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
237 call assert_fails("BackOne('123-456')")
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
238 normal 10g+
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239 call assert_equal('123-', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
240
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241 :" 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
242 call test_settime(103)
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
243 call feedkeys("Aa\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
244 call feedkeys("Ab\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
245 call feedkeys("Ac\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
246 call assert_equal('123-abc', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
247 earlier 1s
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
248 call assert_equal('123-', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
249 earlier 3s
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
250 call assert_equal('123-456', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
251 later 1s
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
252 call assert_equal('123-', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
253 later 1h
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
254 call assert_equal('123-abc', getline(1))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
256 close!
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
257 endfunc
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
258
10049
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
259 func Test_undolist()
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
260 new
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
261 set ul=100
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
262
14015
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
263 let a = execute('undolist')
10049
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
264 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
265
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
266 " 1 leaf (2 changes).
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
267 call feedkeys('achange1', 'xt')
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
268 call feedkeys('achange2', 'xt')
14015
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
269 let a = execute('undolist')
10049
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
270 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
271
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
272 " 2 leaves.
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
273 call feedkeys('u', 'xt')
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
274 call feedkeys('achange3\<Esc>', 'xt')
14015
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
275 let a = execute('undolist')
10049
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
276 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
277 close!
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
278 endfunc
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
279
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
280 func Test_U_command()
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
281 new
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
282 set ul=100
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
283 call feedkeys("achange1\<Esc>", 'xt')
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
284 call feedkeys("achange2\<Esc>", 'xt')
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
285 norm! U
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
286 call assert_equal('', getline(1))
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
287 norm! U
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
288 call assert_equal('change1change2', getline(1))
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
289 close!
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
290 endfunc
efc8a434f38f commit https://github.com/vim/vim/commit/c628fdcd46e93c308f742efdf54248695960e290
Christian Brabandt <cb@256bit.org>
parents: 9674
diff changeset
291
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
292 func Test_undojoin()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
293 new
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
294 call feedkeys("Goaaaa\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
295 call feedkeys("obbbb\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
296 call assert_equal(['aaaa', 'bbbb'], getline(2, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
297 call feedkeys("u", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
298 call assert_equal(['aaaa'], getline(2, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
299 call feedkeys("obbbb\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
300 undojoin
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301 " 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
302 call feedkeys("occcc\<Esc>", 'x')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
303 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
304 call feedkeys("u", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
305 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
306 bwipe!
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
307 endfunc
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
308
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
309 func Test_undojoin_redo()
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
310 new
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
311 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
312 call feedkeys("ixx\<Esc>", 'xt')
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
313 call feedkeys(":undojoin | redo\<CR>", 'xt')
cbf17371627c patch 8.0.0205: wrong behavior after :undojoin
Christian Brabandt <cb@256bit.org>
parents: 10518
diff changeset
314 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
315 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
316 bwipe!
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
317 endfunc
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
318
18902
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
319 " undojoin not allowed after undo
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
320 func Test_undojoin_after_undo()
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
321 new
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
322 call feedkeys("ixx\<Esc>u", 'xt')
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
323 call assert_fails(':undojoin', 'E790:')
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
324 bwipe!
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
325 endfunc
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
326
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
327 " undojoin is a noop when no change yet, or when 'undolevels' is negative
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
328 func Test_undojoin_noop()
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
329 new
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
330 call feedkeys(":undojoin\<CR>", 'xt')
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
331 call assert_equal([''], getline(1, '$'))
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
332 setlocal undolevels=-1
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
333 call feedkeys("ixx\<Esc>u", 'xt')
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
334 call feedkeys(":undojoin\<CR>", 'xt')
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
335 call assert_equal(['xx'], getline(1, '$'))
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
336 bwipe!
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
337 endfunc
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
338
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
339 func Test_undo_write()
12779
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12686
diff changeset
340 call delete('Xtest')
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
341 split Xtest
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
342 call feedkeys("ione one one\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
343 w!
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
344 call feedkeys("otwo\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
345 call feedkeys("otwo\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
346 w
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
347 call feedkeys("othree\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
348 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
349 earlier 1f
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
350 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
351 earlier 1f
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
352 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
353 earlier 1f
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
354 call assert_equal([''], getline(1, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
355 later 1f
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
356 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
357 later 1f
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
358 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
359 later 1f
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
360 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
361
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
362 close!
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
363 call delete('Xtest')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
364 bwipe! Xtest
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 18902
diff changeset
365
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 18902
diff changeset
366 call assert_fails('earlier xyz', 'E475:')
9674
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
367 endfunc
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369 func Test_insert_expr()
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
370 new
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
371 " calling setline() triggers undo sync
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
372 call feedkeys("oa\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
373 call feedkeys("ob\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
374 set ul=100
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
375 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
376 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
377 call feedkeys("u", 'x')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
378 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
379 call feedkeys("u", 'x')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
380 call assert_equal(['a', 'b'], getline(2, '$'))
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
382 call feedkeys("oc\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
383 set ul=100
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
384 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
385 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
386 call feedkeys("u", 'x')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
387 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
388
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
389 call feedkeys("od\<Esc>", 'xt')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
390 set ul=100
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
391 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
392 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
393 call feedkeys("u", 'x')
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394 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
395
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
396 close!
adc7212951ee commit https://github.com/vim/vim/commit/170b10b421f0c9fda08b7cfd3bb043c064f3659a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
397 endfunc
10518
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
398
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
399 func Test_undofile_earlier()
30158
008808e60963 patch 9.0.0415: on MS-Windows some tests are flaky
Bram Moolenaar <Bram@vim.org>
parents: 29752
diff changeset
400 if has('win32')
008808e60963 patch 9.0.0415: on MS-Windows some tests are flaky
Bram Moolenaar <Bram@vim.org>
parents: 29752
diff changeset
401 " FIXME: This test is flaky on MS-Windows.
008808e60963 patch 9.0.0415: on MS-Windows some tests are flaky
Bram Moolenaar <Bram@vim.org>
parents: 29752
diff changeset
402 let g:test_is_flaky = 1
008808e60963 patch 9.0.0415: on MS-Windows some tests are flaky
Bram Moolenaar <Bram@vim.org>
parents: 29752
diff changeset
403 endif
008808e60963 patch 9.0.0415: on MS-Windows some tests are flaky
Bram Moolenaar <Bram@vim.org>
parents: 29752
diff changeset
404
10518
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
405 " Issue #1254
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
406 " 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
407 let t0 = localtime() - 43200
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
408 call test_settime(t0)
29752
b01151812350 patch 9.0.0216: undo earlier test sometimes fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 28835
diff changeset
409 new XfileEarlier
10518
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
410 call feedkeys("ione\<Esc>", 'xt')
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
411 set ul=100
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
412 call test_settime(t0 + 1)
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
413 call feedkeys("otwo\<Esc>", 'xt')
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
414 set ul=100
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
415 call test_settime(t0 + 2)
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
416 call feedkeys("othree\<Esc>", 'xt')
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
417 set ul=100
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
418 w
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
419 wundo Xundofile
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
420 bwipe!
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
421 " restore normal timestamps.
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
422 call test_settime(0)
29752
b01151812350 patch 9.0.0216: undo earlier test sometimes fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 28835
diff changeset
423 new XfileEarlier
10518
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
424 rundo Xundofile
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
425 earlier 1d
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
426 call assert_equal('', getline(1))
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
427 bwipe!
29752
b01151812350 patch 9.0.0216: undo earlier test sometimes fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 28835
diff changeset
428 call delete('XfileEarlier')
10518
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
429 call delete('Xundofile')
de77fa909414 commit https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a
Christian Brabandt <cb@256bit.org>
parents: 10049
diff changeset
430 endfunc
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
431
18902
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
432 func Test_wundo_errors()
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
433 new
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
434 call setline(1, 'hello')
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
435 call assert_fails('wundo! Xdoesnotexist/Xundofile', 'E828:')
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
436 bwipe!
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
437 endfunc
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
438
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
439 " Check that reading a truncated undo file doesn't hang.
17630
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
440 func Test_undofile_truncated()
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
441 new
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
442 call setline(1, 'hello')
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
443 set ul=100
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
444 wundo Xundofile
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
445 let contents = readfile('Xundofile', 'B')
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
446
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
447 " try several sizes
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
448 for size in range(20, 500, 33)
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
449 call writefile(contents[0:size], 'Xundofile', 'D')
17630
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
450 call assert_fails('rundo Xundofile', 'E825:')
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
451 endfor
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
452
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
453 bwipe!
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
454 endfunc
380adf86bf66 patch 8.1.1812: reading a truncted undo file hangs Vim
Bram Moolenaar <Bram@vim.org>
parents: 16702
diff changeset
455
18902
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
456 func Test_rundo_errors()
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
457 call assert_fails('rundo XfileDoesNotExist', 'E822:')
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
458
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
459 call writefile(['abc'], 'Xundofile', 'D')
18902
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
460 call assert_fails('rundo Xundofile', 'E823:')
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
461 endfunc
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
462
22506
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
463 func Test_undofile_next()
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
464 set undofile
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
465 new Xfoo.txt
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
466 execute "norm ix\<c-g>uy\<c-g>uz\<Esc>"
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
467 write
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
468 bwipe
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
469
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
470 next Xfoo.txt
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
471 call assert_equal('xyz', getline(1))
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
472 silent undo
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
473 call assert_equal('xy', getline(1))
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
474 silent undo
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
475 call assert_equal('x', getline(1))
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
476 bwipe!
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
477
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
478 call delete('Xfoo.txt')
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
479 call delete('.Xfoo.txt.un~')
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
480 set undofile&
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
481 endfunc
a6fe2e1ad5b0 patch 8.2.1801: undo file not found when using ":args" or ":next"
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
482
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
483 " Test for undo working properly when executing commands from a register.
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
484 " Also test this in an empty buffer.
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
485 func Test_cmd_in_reg_undo()
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
486 enew!
14015
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
487 let @a = "Ox\<Esc>jAy\<Esc>kdd"
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
488 edit +/^$ test_undo.vim
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
489 normal @au
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
490 call assert_equal(0, &modified)
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
491 return
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
492 new
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
493 normal @au
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
494 call assert_equal(0, &modified)
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
495 only!
14015
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
496 let @a = ''
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
497 endfunc
13117
cfaa513efa3f patch 8.0.1433: illegal memory access after undo
Christian Brabandt <cb@256bit.org>
parents: 12827
diff changeset
498
cfaa513efa3f patch 8.0.1433: illegal memory access after undo
Christian Brabandt <cb@256bit.org>
parents: 12827
diff changeset
499 " This used to cause an illegal memory access
cfaa513efa3f patch 8.0.1433: illegal memory access after undo
Christian Brabandt <cb@256bit.org>
parents: 12827
diff changeset
500 func Test_undo_append()
cfaa513efa3f patch 8.0.1433: illegal memory access after undo
Christian Brabandt <cb@256bit.org>
parents: 12827
diff changeset
501 new
cfaa513efa3f patch 8.0.1433: illegal memory access after undo
Christian Brabandt <cb@256bit.org>
parents: 12827
diff changeset
502 call feedkeys("axx\<Esc>v", 'xt')
cfaa513efa3f patch 8.0.1433: illegal memory access after undo
Christian Brabandt <cb@256bit.org>
parents: 12827
diff changeset
503 undo
cfaa513efa3f patch 8.0.1433: illegal memory access after undo
Christian Brabandt <cb@256bit.org>
parents: 12827
diff changeset
504 norm o
cfaa513efa3f patch 8.0.1433: illegal memory access after undo
Christian Brabandt <cb@256bit.org>
parents: 12827
diff changeset
505 quit
cfaa513efa3f patch 8.0.1433: illegal memory access after undo
Christian Brabandt <cb@256bit.org>
parents: 12827
diff changeset
506 endfunc
13134
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
507
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
508 func Test_undo_0()
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
509 new
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
510 set ul=100
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
511 normal i1
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
512 undo
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
513 normal i2
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
514 undo
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
515 normal i3
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
516
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
517 undo 0
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
518 let d = undotree()
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
519 call assert_equal('', getline(1))
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
520 call assert_equal(0, d.seq_cur)
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
521
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
522 redo
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
523 let d = undotree()
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
524 call assert_equal('3', getline(1))
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
525 call assert_equal(3, d.seq_cur)
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
526
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
527 undo 2
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
528 undo 0
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
529 let d = undotree()
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
530 call assert_equal('', getline(1))
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
531 call assert_equal(0, d.seq_cur)
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
532
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
533 redo
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
534 let d = undotree()
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
535 call assert_equal('2', getline(1))
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
536 call assert_equal(2, d.seq_cur)
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
537
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
538 undo 1
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
539 undo 0
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
540 let d = undotree()
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
541 call assert_equal('', getline(1))
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
542 call assert_equal(0, d.seq_cur)
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
543
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
544 redo
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
545 let d = undotree()
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
546 call assert_equal('1', getline(1))
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
547 call assert_equal(1, d.seq_cur)
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
548
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
549 bwipe!
c4b5ad2b3596 patch 8.0.1441: using ":undo 0" leaves undo in wrong state
Christian Brabandt <cb@256bit.org>
parents: 13117
diff changeset
550 endfunc
13202
2941a86f8aaa patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents: 13134
diff changeset
551
18902
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
552 " undo or redo are noop if there is nothing to undo or redo
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
553 func Test_undo_redo_noop()
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
554 new
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
555 call assert_fails('undo 2', 'E830:')
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
556
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
557 message clear
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
558 undo
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
559 let messages = split(execute('message'), "\n")
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
560 call assert_equal('Already at oldest change', messages[-1])
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
561
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
562 message clear
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
563 redo
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
564 let messages = split(execute('message'), "\n")
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
565 call assert_equal('Already at newest change', messages[-1])
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
566
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
567 bwipe!
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
568 endfunc
b24648ebcbc9 patch 8.2.0012: some undo functionality is not tested
Bram Moolenaar <Bram@vim.org>
parents: 18894
diff changeset
569
13202
2941a86f8aaa patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents: 13134
diff changeset
570 func Test_redo_empty_line()
2941a86f8aaa patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents: 13134
diff changeset
571 new
2941a86f8aaa patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents: 13134
diff changeset
572 exe "norm\x16r\x160"
2941a86f8aaa patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents: 13134
diff changeset
573 exe "norm."
2941a86f8aaa patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents: 13134
diff changeset
574 bwipe!
2941a86f8aaa patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents: 13134
diff changeset
575 endfunc
14015
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
576
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
577 funct Test_undofile()
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
578 " Test undofile() without setting 'undodir'.
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
579 if has('persistent_undo')
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
580 call assert_equal(fnamemodify('.Xundofoo.un~', ':p'), undofile('Xundofoo'))
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
581 else
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
582 call assert_equal('', undofile('Xundofoo'))
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
583 endif
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
584 call assert_equal('', undofile(''))
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
585
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
586 " Test undofile() with 'undodir' set to to an existing directory.
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
587 call mkdir('Xundodir')
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
588 set undodir=Xundodir
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
589 let cwd = getcwd()
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
590 if has('win32')
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
591 " Replace windows drive such as C:... into C%...
15150
83a366325158 patch 8.1.0585: undo test may fail on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 14015
diff changeset
592 let cwd = substitute(cwd, '^\([a-zA-Z]\):', '\1%', 'g')
14015
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
593 endif
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
594 let cwd = substitute(cwd . '/Xundofoo', '/', '%', 'g')
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
595 if has('persistent_undo')
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
596 call assert_equal('Xundodir/' . cwd, undofile('Xundofoo'))
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
597 else
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
598 call assert_equal('', undofile('Xundofoo'))
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
599 endif
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
600 call assert_equal('', undofile(''))
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
601 call delete('Xundodir', 'd')
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
602
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
603 " Test undofile() with 'undodir' set to a non-existing directory.
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17630
diff changeset
604 call assert_equal('', 'Xundofoo'->undofile())
14015
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
605
18473
0eeaa9a6e4e7 patch 8.1.2230: MS-Windows: testing external commands can be improved
Bram Moolenaar <Bram@vim.org>
parents: 18058
diff changeset
606 if !has('win32') && isdirectory('/tmp')
16700
46322a4e6028 patch 8.1.1352: undofile() reports wrong name
Bram Moolenaar <Bram@vim.org>
parents: 15150
diff changeset
607 set undodir=/tmp
16702
16a698aeeec1 patch 8.1.1353: undo test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 16700
diff changeset
608 if has('osx')
16a698aeeec1 patch 8.1.1353: undo test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 16700
diff changeset
609 call assert_equal('/tmp/%private%tmp%file', undofile('///tmp/file'))
16a698aeeec1 patch 8.1.1353: undo test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 16700
diff changeset
610 else
16a698aeeec1 patch 8.1.1353: undo test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 16700
diff changeset
611 call assert_equal('/tmp/%tmp%file', undofile('///tmp/file'))
16a698aeeec1 patch 8.1.1353: undo test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 16700
diff changeset
612 endif
16700
46322a4e6028 patch 8.1.1352: undofile() reports wrong name
Bram Moolenaar <Bram@vim.org>
parents: 15150
diff changeset
613 endif
46322a4e6028 patch 8.1.1352: undofile() reports wrong name
Bram Moolenaar <Bram@vim.org>
parents: 15150
diff changeset
614
14015
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
615 set undodir&
9709d783261f patch 8.1.0025: no test for the undofile() function
Christian Brabandt <cb@256bit.org>
parents: 13202
diff changeset
616 endfunc
18894
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
617
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
618 " Tests for the undo file
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
619 " Explicitly break changes up in undo-able pieces by setting 'undolevels'.
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
620 func Test_undofile_2()
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
621 set undolevels=100 undofile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
622 edit Xtestfile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
623 call append(0, 'this is one line')
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
624 call cursor(1, 1)
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
625
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
626 " first a simple one-line change.
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
627 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
628 s/one/ONE/
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
629 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
630 write
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
631 bwipe!
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
632 edit Xtestfile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
633 undo
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
634 call assert_equal('this is one line', getline(1))
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
635
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
636 " change in original file fails check
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
637 set noundofile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
638 edit! Xtestfile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
639 s/line/Line/
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
640 write
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
641 set undofile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
642 bwipe!
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
643 edit Xtestfile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
644 undo
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
645 call assert_equal('this is ONE Line', getline(1))
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
646
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
647 " add 10 lines, delete 6 lines, undo 3
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
648 set undofile
25654
ef38fc02faaa patch 8.2.3363: when :edit reuses the current buffer the alternate file is set
Bram Moolenaar <Bram@vim.org>
parents: 24204
diff changeset
649 call setbufline('%', 1, ['one', 'two', 'three', 'four', 'five', 'six',
18894
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
650 \ 'seven', 'eight', 'nine', 'ten'])
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
651 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
652 normal 3Gdd
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
653 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
654 normal dd
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
655 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
656 normal dd
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
657 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
658 normal dd
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
659 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
660 normal dd
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
661 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
662 normal dd
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
663 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
664 write
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
665 bwipe!
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
666 edit Xtestfile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
667 normal uuu
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
668 call assert_equal(['one', 'two', 'six', 'seven', 'eight', 'nine', 'ten'],
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
669 \ getline(1, '$'))
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
670
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
671 " Test that reading the undofiles when setting undofile works
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
672 set noundofile undolevels=0
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
673 exe "normal i\n"
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
674 undo
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
675 edit! Xtestfile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
676 set undofile undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
677 normal uuuuuu
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
678 call assert_equal(['one', 'two', 'three', 'four', 'five', 'six', 'seven',
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
679 \ 'eight', 'nine', 'ten'], getline(1, '$'))
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
680
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
681 bwipe!
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
682 call delete('Xtestfile')
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
683 let ufile = has('vms') ? '_un_Xtestfile' : '.Xtestfile.un~'
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
684 call delete(ufile)
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
685 set undofile& undolevels&
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
686 endfunc
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
687
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
688 " Test 'undofile' using a file encrypted with 'zip' crypt method
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
689 func Test_undofile_cryptmethod_zip()
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
690 edit Xtestfile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
691 set undofile cryptmethod=zip
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
692 call append(0, ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'])
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
693 call cursor(5, 1)
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
694
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
695 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
696 normal kkkdd
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
697 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
698 normal dd
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
699 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
700 normal dd
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
701 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
702 " encrypt the file using key 'foobar'
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
703 call feedkeys("foobar\nfoobar\n")
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
704 X
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
705 write!
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
706 bwipe!
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
707
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
708 call feedkeys("foobar\n")
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
709 edit Xtestfile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
710 set key=
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
711 normal uu
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
712 call assert_equal(['monday', 'wednesday', 'thursday', 'friday', ''],
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
713 \ getline(1, '$'))
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
714
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
715 bwipe!
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
716 call delete('Xtestfile')
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
717 let ufile = has('vms') ? '_un_Xtestfile' : '.Xtestfile.un~'
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
718 call delete(ufile)
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
719 set undofile& undolevels& cryptmethod&
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
720 endfunc
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
721
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
722 " Test 'undofile' using a file encrypted with 'blowfish' crypt method
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
723 func Test_undofile_cryptmethod_blowfish()
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
724 edit Xtestfile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
725 set undofile cryptmethod=blowfish
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
726 call append(0, ['jan', 'feb', 'mar', 'apr', 'jun'])
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
727 call cursor(5, 1)
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
728
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
729 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
730 exe 'normal kk0ifoo '
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
731 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
732 normal dd
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
733 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
734 exe 'normal ibar '
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
735 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
736 " encrypt the file using key 'foobar'
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
737 call feedkeys("foobar\nfoobar\n")
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
738 X
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
739 write!
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
740 bwipe!
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
741
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
742 call feedkeys("foobar\n")
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
743 edit Xtestfile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
744 set key=
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
745 call search('bar')
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
746 call assert_equal('bar apr', getline('.'))
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
747 undo
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
748 call assert_equal('apr', getline('.'))
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
749 undo
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
750 call assert_equal('foo mar', getline('.'))
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
751 undo
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
752 call assert_equal('mar', getline('.'))
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
753
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
754 bwipe!
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
755 call delete('Xtestfile')
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
756 let ufile = has('vms') ? '_un_Xtestfile' : '.Xtestfile.un~'
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
757 call delete(ufile)
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
758 set undofile& undolevels& cryptmethod&
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
759 endfunc
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
760
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
761 " Test 'undofile' using a file encrypted with 'blowfish2' crypt method
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
762 func Test_undofile_cryptmethod_blowfish2()
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
763 edit Xtestfile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
764 set undofile cryptmethod=blowfish2
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
765 call append(0, ['jan', 'feb', 'mar', 'apr', 'jun'])
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
766 call cursor(5, 1)
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
767
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
768 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
769 exe 'normal kk0ifoo '
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
770 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
771 normal dd
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
772 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
773 exe 'normal ibar '
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
774 set undolevels=100
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
775 " encrypt the file using key 'foo2bar'
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
776 call feedkeys("foo2bar\nfoo2bar\n")
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
777 X
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
778 write!
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
779 bwipe!
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
780
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
781 call feedkeys("foo2bar\n")
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
782 edit Xtestfile
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
783 set key=
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
784 call search('bar')
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
785 call assert_equal('bar apr', getline('.'))
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
786 normal u
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
787 call assert_equal('apr', getline('.'))
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
788 normal u
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
789 call assert_equal('foo mar', getline('.'))
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
790 normal u
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
791 call assert_equal('mar', getline('.'))
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
792
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
793 bwipe!
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
794 call delete('Xtestfile')
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
795 let ufile = has('vms') ? '_un_Xtestfile' : '.Xtestfile.un~'
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
796 call delete(ufile)
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
797 set undofile& undolevels& cryptmethod&
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
798 endfunc
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
799
24134
72e9b861bc92 patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 22506
diff changeset
800 " Test for redoing with incrementing numbered registers
72e9b861bc92 patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 22506
diff changeset
801 func Test_redo_repeat_numbered_register()
72e9b861bc92 patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 22506
diff changeset
802 new
72e9b861bc92 patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 22506
diff changeset
803 for [i, v] in [[1, 'one'], [2, 'two'], [3, 'three'],
72e9b861bc92 patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 22506
diff changeset
804 \ [4, 'four'], [5, 'five'], [6, 'six'],
72e9b861bc92 patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 22506
diff changeset
805 \ [7, 'seven'], [8, 'eight'], [9, 'nine']]
72e9b861bc92 patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 22506
diff changeset
806 exe 'let @' .. i .. '="' .. v .. '\n"'
72e9b861bc92 patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 22506
diff changeset
807 endfor
72e9b861bc92 patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 22506
diff changeset
808 call feedkeys('"1p.........', 'xt')
72e9b861bc92 patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 22506
diff changeset
809 call assert_equal(['', 'one', 'two', 'three', 'four', 'five', 'six',
72e9b861bc92 patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 22506
diff changeset
810 \ 'seven', 'eight', 'nine', 'nine'], getline(1, '$'))
72e9b861bc92 patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 22506
diff changeset
811 bwipe!
72e9b861bc92 patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 22506
diff changeset
812 endfunc
72e9b861bc92 patch 8.2.2608: character input not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 22506
diff changeset
813
24204
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24134
diff changeset
814 " Test for redo in insert mode using CTRL-O with multibyte characters
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24134
diff changeset
815 func Test_redo_multibyte_in_insert_mode()
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24134
diff changeset
816 new
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24134
diff changeset
817 call feedkeys("a\<C-K>ft", 'xt')
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24134
diff changeset
818 call feedkeys("uiHe\<C-O>.llo", 'xt')
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24134
diff changeset
819 call assert_equal("He\ufb05llo", getline(1))
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24134
diff changeset
820 bwipe!
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24134
diff changeset
821 endfunc
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24134
diff changeset
822
28835
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
823 func Test_undo_mark()
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
824 new
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
825 " The undo is applied to the only line.
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
826 call setline(1, 'hello')
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
827 call feedkeys("ggyiw$p", 'xt')
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
828 undo
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
829 call assert_equal([0, 1, 1, 0], getpos("'["))
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
830 call assert_equal([0, 1, 1, 0], getpos("']"))
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
831 " The undo removes the last line.
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
832 call feedkeys("Goaaaa\<Esc>", 'xt')
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
833 call feedkeys("obbbb\<Esc>", 'xt')
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
834 undo
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
835 call assert_equal([0, 2, 1, 0], getpos("'["))
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
836 call assert_equal([0, 2, 1, 0], getpos("']"))
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
837 bwipe!
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
838 endfunc
58d2315b096e patch 8.2.4941: '[ and '] marks may be wrong after undo
Bram Moolenaar <Bram@vim.org>
parents: 25654
diff changeset
839
31406
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
840 func Test_undo_after_write()
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
841 " use a terminal to make undo work like when text is typed
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
842 CheckRunVimInTerminal
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
843
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
844 let lines =<< trim END
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
845 edit Xtestfile.txt
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
846 set undolevels=100 undofile
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
847 imap . <Cmd>write<CR>
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
848 write
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
849 END
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
850 call writefile(lines, 'Xtest_undo_after_write', 'D')
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
851 let buf = RunVimInTerminal('-S Xtest_undo_after_write', #{rows: 6})
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
852
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
853 call term_sendkeys(buf, "Otest.\<CR>boo!!!\<Esc>")
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
854 sleep 100m
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
855 call term_sendkeys(buf, "u")
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
856 call VerifyScreenDump(buf, 'Test_undo_after_write_1', {})
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
857
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
858 call term_sendkeys(buf, "u")
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
859 call VerifyScreenDump(buf, 'Test_undo_after_write_2', {})
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
860
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
861 call StopVimInTerminal(buf)
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
862 call delete('Xtestfile.txt')
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
863 endfunc
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
864
33171
db2e9816e400 patch 9.0.1866: undo is synced after character find
Christian Brabandt <cb@256bit.org>
parents: 32909
diff changeset
865 func Test_undo_range_normal()
db2e9816e400 patch 9.0.1866: undo is synced after character find
Christian Brabandt <cb@256bit.org>
parents: 32909
diff changeset
866 new
db2e9816e400 patch 9.0.1866: undo is synced after character find
Christian Brabandt <cb@256bit.org>
parents: 32909
diff changeset
867 call setline(1, ['asa', 'bsb'])
db2e9816e400 patch 9.0.1866: undo is synced after character find
Christian Brabandt <cb@256bit.org>
parents: 32909
diff changeset
868 let &l:undolevels = &l:undolevels
db2e9816e400 patch 9.0.1866: undo is synced after character find
Christian Brabandt <cb@256bit.org>
parents: 32909
diff changeset
869 %normal dfs
db2e9816e400 patch 9.0.1866: undo is synced after character find
Christian Brabandt <cb@256bit.org>
parents: 32909
diff changeset
870 call assert_equal(['a', 'b'], getline(1, '$'))
db2e9816e400 patch 9.0.1866: undo is synced after character find
Christian Brabandt <cb@256bit.org>
parents: 32909
diff changeset
871 undo
db2e9816e400 patch 9.0.1866: undo is synced after character find
Christian Brabandt <cb@256bit.org>
parents: 32909
diff changeset
872 call assert_equal(['asa', 'bsb'], getline(1, '$'))
db2e9816e400 patch 9.0.1866: undo is synced after character find
Christian Brabandt <cb@256bit.org>
parents: 32909
diff changeset
873 bwipe!
db2e9816e400 patch 9.0.1866: undo is synced after character find
Christian Brabandt <cb@256bit.org>
parents: 32909
diff changeset
874 endfunc
31406
627d4f236ac8 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
875
18894
aad0d64cc133 patch 8.2.0008: test72 is old style
Bram Moolenaar <Bram@vim.org>
parents: 18473
diff changeset
876 " vim: shiftwidth=2 sts=2 expandtab