annotate src/testdir/test_fold.vim @ 12750:0b6c09957b43 v8.0.1253

patch 8.0.1253: still too many old style tests commit https://github.com/vim/vim/commit/430dc5d360166ca5bb6a73f2c87ae53e09282ecb Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 2 21:04:47 2017 +0100 patch 8.0.1253: still too many old style tests Problem: Still too many old style tests. Solution: Convert a few more tests to new style. (Yegappan Lakshmanan, closes #2272)
author Christian Brabandt <cb@256bit.org>
date Thu, 02 Nov 2017 21:15:05 +0100
parents f6534b99b76f
children cb9b2774f21f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10484
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test for folding
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
3 func PrepIndent(arg)
11140
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
4 return [a:arg] + repeat(["\t".a:arg], 5)
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
5 endfu
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
6
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
7 func Test_address_fold()
10484
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 new
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 call setline(1, ['int FuncName() {/*{{{*/', 1, 2, 3, 4, 5, '}/*}}}*/',
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 \ 'after fold 1', 'after fold 2', 'after fold 3'])
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 setl fen fdm=marker
11219
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
12 " The next commands should all copy the same part of the buffer,
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
13 " regardless of the addressing type, since the part to be copied
10484
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 " is folded away
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 :1y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 :.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 :.+y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 :.,.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 :sil .1,.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 " use silent to make E493 go away
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 :sil .+,.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 :,y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 :,+y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/','after fold 1'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 " using .+3 as second address should copy the whole folded line + the next 3
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 " lines
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 :.,+3y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/',
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 \ 'after fold 1', 'after fold 2', 'after fold 3'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 :sil .,-2y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 " now test again with folding disabled
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 set nofoldenable
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 :1y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 call assert_equal(['int FuncName() {/*{{{*/'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 :.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 call assert_equal(['int FuncName() {/*{{{*/'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 :.+y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 call assert_equal(['1'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 :.,.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 call assert_equal(['int FuncName() {/*{{{*/'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 " use silent to make E493 go away
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 :sil .1,.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call assert_equal(['int FuncName() {/*{{{*/', '1'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 " use silent to make E493 go away
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 :sil .+,.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 call assert_equal(['int FuncName() {/*{{{*/', '1'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 :,y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 call assert_equal(['int FuncName() {/*{{{*/'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 :,+y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 call assert_equal(['int FuncName() {/*{{{*/', '1'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 " using .+3 as second address should copy the whole folded line + the next 3
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 " lines
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 :.,+3y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 :7
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 :sil .,-2y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 call assert_equal(['4', '5', '}/*}}}*/'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 quit!
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
69 endfunc
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
70
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
71 func Test_indent_fold()
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
72 new
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
73 call setline(1, ['', 'a', ' b', ' c'])
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
74 setl fen fdm=indent
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
75 2
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
76 norm! >>
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
77 let a=map(range(1,4), 'foldclosed(v:val)')
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
78 call assert_equal([-1,-1,-1,-1], a)
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
79 bw!
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
80 endfunc
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
81
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
82 func Test_indent_fold2()
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
83 new
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
84 call setline(1, ['', '{{{', '}}}', '{{{', '}}}'])
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
85 setl fen fdm=marker
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
86 2
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
87 norm! >>
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
88 let a=map(range(1,5), 'foldclosed(v:val)')
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
89 call assert_equal([-1,-1,-1,4,4], a)
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
90 bw!
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
91 endfunc
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
92
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
93 func Test_manual_fold_with_filter()
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
94 if !executable('cat')
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
95 return
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
96 endif
11036
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
97 for type in ['manual', 'marker']
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
98 exe 'set foldmethod=' . type
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
99 new
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
100 call setline(1, range(1, 20))
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
101 4,$fold
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
102 %foldopen
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
103 10,$fold
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
104 %foldopen
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
105 " This filter command should not have an effect
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
106 1,8! cat
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
107 call feedkeys('5ggzdzMGdd', 'xt')
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
108 call assert_equal(['1', '2', '3', '4', '5', '6', '7', '8', '9'], getline(1, '$'))
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
109
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
110 bwipe!
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
111 set foldmethod&
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
112 endfor
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
113 endfunc
11038
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
114
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
115 func Test_indent_fold_with_read()
11038
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
116 new
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
117 set foldmethod=indent
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
118 call setline(1, repeat(["\<Tab>a"], 4))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
119 for n in range(1, 4)
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
120 call assert_equal(1, foldlevel(n))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
121 endfor
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
122
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
123 call writefile(["a", "", "\<Tab>a"], 'Xfile')
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
124 foldopen
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
125 2read Xfile
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
126 %foldclose
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
127 call assert_equal(1, foldlevel(1))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
128 call assert_equal(2, foldclosedend(1))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
129 call assert_equal(0, foldlevel(3))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
130 call assert_equal(0, foldlevel(4))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
131 call assert_equal(1, foldlevel(5))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
132 call assert_equal(7, foldclosedend(5))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
133
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
134 bwipe!
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
135 set foldmethod&
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
136 call delete('Xfile')
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
137 endfunc
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
138
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
139 func Test_combining_folds_indent()
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
140 new
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
141 let one = "\<Tab>a"
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
142 let zero = 'a'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
143 call setline(1, [one, one, zero, zero, zero, one, one, one])
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
144 set foldmethod=indent
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
145 3,5d
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
146 %foldclose
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
147 call assert_equal(5, foldclosedend(1))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
148
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
149 set foldmethod&
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
150 bwipe!
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
151 endfunc
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
152
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
153 func Test_combining_folds_marker()
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
154 new
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
155 call setline(1, ['{{{', '}}}', '', '', '', '{{{', '', '}}}'])
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
156 set foldmethod=marker
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
157 3,5d
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
158 %foldclose
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
159 call assert_equal(2, foldclosedend(1))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
160
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
161 set foldmethod&
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
162 bwipe!
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
163 endfunc
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
164
11131
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
165 func Test_folds_marker_in_comment()
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
166 new
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
167 call setline(1, ['" foo', 'bar', 'baz'])
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
168 setl fen fdm=marker
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
169 setl com=sO:\"\ -,mO:\"\ \ ,eO:\"\",:\" cms=\"%s
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
170 norm! zf2j
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
171 setl nofen
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
172 :1y
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
173 call assert_equal(['" foo{{{'], getreg(0,1,1))
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
174 :+2y
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
175 call assert_equal(['baz"}}}'], getreg(0,1,1))
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
176
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
177 set foldmethod&
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
178 bwipe!
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
179 endfunc
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
180
11038
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
181 func s:TestFoldExpr(lnum)
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
182 let thisline = getline(a:lnum)
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
183 if thisline == 'a'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
184 return 1
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
185 elseif thisline == 'b'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
186 return 0
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
187 elseif thisline == 'c'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
188 return '<1'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
189 elseif thisline == 'd'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
190 return '>1'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
191 endif
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
192 return 0
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
193 endfunction
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
194
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
195 func Test_update_folds_expr_read()
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
196 new
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
197 call setline(1, ['a', 'a', 'a', 'a', 'a', 'a'])
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
198 set foldmethod=expr
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
199 set foldexpr=s:TestFoldExpr(v:lnum)
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
200 2
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
201 foldopen
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
202 call writefile(['b', 'b', 'a', 'a', 'd', 'a', 'a', 'c'], 'Xfile')
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
203 read Xfile
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
204 %foldclose
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
205 call assert_equal(2, foldclosedend(1))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
206 call assert_equal(0, foldlevel(3))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
207 call assert_equal(0, foldlevel(4))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
208 call assert_equal(6, foldclosedend(5))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
209 call assert_equal(10, foldclosedend(7))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
210 call assert_equal(14, foldclosedend(11))
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
211
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
212 call delete('Xfile')
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
213 bwipe!
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
214 set foldmethod& foldexpr&
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
215 endfunc
11140
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
216
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
217 func Check_foldlevels(expected)
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
218 call assert_equal(a:expected, map(range(1, line('$')), 'foldlevel(v:val)'))
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
219 endfunc
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
220
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
221 func Test_move_folds_around_manual()
11140
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
222 new
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
223 let input = PrepIndent("a") + PrepIndent("b") + PrepIndent("c")
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
224 call setline(1, PrepIndent("a") + PrepIndent("b") + PrepIndent("c"))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
225 let folds=[-1, 2, 2, 2, 2, 2, -1, 8, 8, 8, 8, 8, -1, 14, 14, 14, 14, 14]
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
226 " all folds closed
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
227 set foldenable foldlevel=0 fdm=indent
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
228 " needs a forced redraw
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
229 redraw!
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
230 set fdm=manual
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
231 call assert_equal(folds, map(range(1, line('$')), 'foldclosed(v:val)'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
232 call assert_equal(input, getline(1, '$'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
233 7,12m0
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
234 call assert_equal(PrepIndent("b") + PrepIndent("a") + PrepIndent("c"), getline(1, '$'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
235 call assert_equal(folds, map(range(1, line('$')), 'foldclosed(v:val)'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
236 10,12m0
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
237 call assert_equal(PrepIndent("a")[1:] + PrepIndent("b") + ["a"] + PrepIndent("c"), getline(1, '$'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
238 call assert_equal([1, 1, 1, 1, 1, -1, 7, 7, 7, 7, 7, -1, -1, 14, 14, 14, 14, 14], map(range(1, line('$')), 'foldclosed(v:val)'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
239 " moving should not close the folds
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
240 %d
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
241 call setline(1, PrepIndent("a") + PrepIndent("b") + PrepIndent("c"))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
242 set fdm=indent
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
243 redraw!
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
244 set fdm=manual
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
245 call cursor(2, 1)
11156
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
246 %foldopen
11140
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
247 7,12m0
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
248 let folds=repeat([-1], 18)
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
249 call assert_equal(PrepIndent("b") + PrepIndent("a") + PrepIndent("c"), getline(1, '$'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
250 call assert_equal(folds, map(range(1, line('$')), 'foldclosed(v:val)'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
251 norm! zM
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
252 " folds are not corrupted and all have been closed
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
253 call assert_equal([-1, 2, 2, 2, 2, 2, -1, 8, 8, 8, 8, 8, -1, 14, 14, 14, 14, 14], map(range(1, line('$')), 'foldclosed(v:val)'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
254 %d
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
255 call setline(1, ["a", "\tb", "\tc", "\td", "\te"])
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
256 set fdm=indent
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
257 redraw!
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
258 set fdm=manual
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
259 %foldopen
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
260 3m4
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
261 %foldclose
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
262 call assert_equal(["a", "\tb", "\td", "\tc", "\te"], getline(1, '$'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
263 call assert_equal([-1, 5, 5, 5, 5], map(range(1, line('$')), 'foldclosedend(v:val)'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
264 %d
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
265 call setline(1, ["a", "\tb", "\tc", "\td", "\te", "z", "\ty", "\tx", "\tw", "\tv"])
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
266 set fdm=indent foldlevel=0
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
267 set fdm=manual
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
268 %foldopen
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
269 3m1
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
270 %foldclose
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
271 call assert_equal(["a", "\tc", "\tb", "\td", "\te", "z", "\ty", "\tx", "\tw", "\tv"], getline(1, '$'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
272 call assert_equal(0, foldlevel(2))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
273 call assert_equal(5, foldclosedend(3))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
274 call assert_equal([-1, -1, 3, 3, 3, -1, 7, 7, 7, 7], map(range(1, line('$')), 'foldclosed(v:val)'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
275 2,6m$
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
276 %foldclose
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
277 call assert_equal(5, foldclosedend(2))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
278 call assert_equal(0, foldlevel(6))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
279 call assert_equal(9, foldclosedend(7))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
280 call assert_equal([-1, 2, 2, 2, 2, -1, 7, 7, 7, -1], map(range(1, line('$')), 'foldclosed(v:val)'))
12471
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
281
11156
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
282 %d
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
283 " Ensure moving around the edges still works.
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
284 call setline(1, PrepIndent("a") + repeat(["a"], 3) + ["\ta"])
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
285 set fdm=indent foldlevel=0
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
286 set fdm=manual
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
287 %foldopen
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
288 6m$
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
289 " The first fold has been truncated to the 5'th line.
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
290 " Second fold has been moved up because the moved line is now below it.
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
291 call Check_foldlevels([0, 1, 1, 1, 1, 0, 0, 0, 1, 0])
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
292
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
293 %delete
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
294 set fdm=indent foldlevel=0
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
295 call setline(1, [
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
296 \ "a",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
297 \ "\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
298 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
299 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
300 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
301 \ "a",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
302 \ "a"])
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
303 set fdm=manual
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
304 %foldopen!
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
305 4,5m6
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
306 call Check_foldlevels([0, 1, 2, 0, 0, 0, 0])
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
307
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
308 %delete
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
309 set fdm=indent
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
310 call setline(1, [
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
311 \ "\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
312 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
313 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
314 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
315 \ "\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
316 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
317 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
318 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
319 \ "\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
320 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
321 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
322 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
323 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
324 \ "\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
325 \ "a"])
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
326 set fdm=manual
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
327 %foldopen!
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
328 13m7
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
329 call Check_foldlevels([1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 0])
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
330
11140
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
331 bw!
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
332 endfunc
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
333
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
334 func Test_move_folds_around_indent()
11140
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
335 new
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
336 let input = PrepIndent("a") + PrepIndent("b") + PrepIndent("c")
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
337 call setline(1, PrepIndent("a") + PrepIndent("b") + PrepIndent("c"))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
338 let folds=[-1, 2, 2, 2, 2, 2, -1, 8, 8, 8, 8, 8, -1, 14, 14, 14, 14, 14]
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
339 " all folds closed
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
340 set fdm=indent
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
341 call assert_equal(folds, map(range(1, line('$')), 'foldclosed(v:val)'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
342 call assert_equal(input, getline(1, '$'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
343 7,12m0
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
344 call assert_equal(PrepIndent("b") + PrepIndent("a") + PrepIndent("c"), getline(1, '$'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
345 call assert_equal(folds, map(range(1, line('$')), 'foldclosed(v:val)'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
346 10,12m0
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
347 call assert_equal(PrepIndent("a")[1:] + PrepIndent("b") + ["a"] + PrepIndent("c"), getline(1, '$'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
348 call assert_equal([1, 1, 1, 1, 1, -1, 7, 7, 7, 7, 7, -1, -1, 14, 14, 14, 14, 14], map(range(1, line('$')), 'foldclosed(v:val)'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
349 " moving should not close the folds
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
350 %d
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
351 call setline(1, PrepIndent("a") + PrepIndent("b") + PrepIndent("c"))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
352 set fdm=indent
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
353 call cursor(2, 1)
11156
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
354 %foldopen
11140
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
355 7,12m0
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
356 let folds=repeat([-1], 18)
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
357 call assert_equal(PrepIndent("b") + PrepIndent("a") + PrepIndent("c"), getline(1, '$'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
358 call assert_equal(folds, map(range(1, line('$')), 'foldclosed(v:val)'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
359 norm! zM
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
360 " folds are not corrupted and all have been closed
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
361 call assert_equal([-1, 2, 2, 2, 2, 2, -1, 8, 8, 8, 8, 8, -1, 14, 14, 14, 14, 14], map(range(1, line('$')), 'foldclosed(v:val)'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
362 %d
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
363 call setline(1, ["a", "\tb", "\tc", "\td", "\te"])
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
364 set fdm=indent
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
365 %foldopen
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
366 3m4
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
367 %foldclose
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
368 call assert_equal(["a", "\tb", "\td", "\tc", "\te"], getline(1, '$'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
369 call assert_equal([-1, 5, 5, 5, 5], map(range(1, line('$')), 'foldclosedend(v:val)'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
370 %d
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
371 call setline(1, ["a", "\tb", "\tc", "\td", "\te", "z", "\ty", "\tx", "\tw", "\tv"])
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
372 set fdm=indent foldlevel=0
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
373 %foldopen
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
374 3m1
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
375 %foldclose
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
376 call assert_equal(["a", "\tc", "\tb", "\td", "\te", "z", "\ty", "\tx", "\tw", "\tv"], getline(1, '$'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
377 call assert_equal(1, foldlevel(2))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
378 call assert_equal(5, foldclosedend(3))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
379 call assert_equal([-1, 2, 2, 2, 2, -1, 7, 7, 7, 7], map(range(1, line('$')), 'foldclosed(v:val)'))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
380 2,6m$
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
381 %foldclose
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
382 call assert_equal(9, foldclosedend(2))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
383 call assert_equal(1, foldlevel(6))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
384 call assert_equal(9, foldclosedend(7))
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
385 call assert_equal([-1, 2, 2, 2, 2, 2, 2, 2, 2, -1], map(range(1, line('$')), 'foldclosed(v:val)'))
11156
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
386 " Ensure moving around the edges still works.
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
387 %d
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
388 call setline(1, PrepIndent("a") + repeat(["a"], 3) + ["\ta"])
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
389 set fdm=indent foldlevel=0
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
390 %foldopen
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
391 6m$
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
392 " The first fold has been truncated to the 5'th line.
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
393 " Second fold has been moved up because the moved line is now below it.
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
394 call Check_foldlevels([0, 1, 1, 1, 1, 0, 0, 0, 1, 1])
11140
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
395 bw!
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
396 endfunc
11219
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
397
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
398 func Test_folddoopen_folddoclosed()
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
399 new
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
400 call setline(1, range(1, 9))
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
401 set foldmethod=manual
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
402 1,3 fold
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
403 6,8 fold
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
404
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
405 " Test without range.
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
406 folddoopen s/$/o/
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
407 folddoclosed s/$/c/
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
408 call assert_equal(['1c', '2c', '3c',
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
409 \ '4o', '5o',
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
410 \ '6c', '7c', '8c',
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
411 \ '9o'], getline(1, '$'))
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
412
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
413 " Test with range.
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
414 call setline(1, range(1, 9))
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
415 1,8 folddoopen s/$/o/
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
416 4,$ folddoclosed s/$/c/
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
417 call assert_equal(['1', '2', '3',
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
418 \ '4o', '5o',
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
419 \ '6c', '7c', '8c',
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
420 \ '9'], getline(1, '$'))
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
421
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
422 set foldmethod&
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
423 bw!
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
424 endfunc
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
425
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
426 func Test_fold_error()
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
427 new
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
428 call setline(1, [1, 2])
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
429
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
430 for fm in ['indent', 'expr', 'syntax', 'diff']
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
431 exe 'set foldmethod=' . fm
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
432 call assert_fails('norm zf', 'E350:')
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
433 call assert_fails('norm zd', 'E351:')
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
434 call assert_fails('norm zE', 'E352:')
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
435 endfor
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
436
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
437 set foldmethod=manual
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
438 call assert_fails('norm zd', 'E490:')
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
439 call assert_fails('norm zo', 'E490:')
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
440 call assert_fails('3fold', 'E16:')
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
441
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
442 set foldmethod=marker
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
443 set nomodifiable
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
444 call assert_fails('1,2fold', 'E21:')
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
445
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
446 set modifiable&
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
447 set foldmethod&
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
448 bw!
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
449 endfunc
12471
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
450
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
451 func Test_foldtext_recursive()
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
452 new
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
453 call setline(1, ['{{{', 'some text', '}}}'])
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
454 setlocal foldenable foldmethod=marker foldtext=foldtextresult(v\:foldstart)
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
455 " This was crashing because of endless recursion.
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
456 2foldclose
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
457 redraw
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
458 call assert_equal(1, foldlevel(2))
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
459 call assert_equal(1, foldclosed(2))
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
460 call assert_equal(3, foldclosedend(2))
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
461 bwipe!
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
462 endfunc
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
463
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
464 " Various fold related tests
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
465
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
466 " Basic test if a fold can be created, opened, moving to the end and closed
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
467 func Test_fold_manual()
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
468 enew!
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
469 set fdm=manual
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
470
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
471 let content = ['1 aa', '2 bb', '3 cc']
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
472 call append(0, content)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
473 call cursor(1, 1)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
474 normal zf2j
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
475 call assert_equal('1 aa', getline(foldclosed('.')))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
476 normal zo
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
477 call assert_equal(-1, foldclosed('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
478 normal ]z
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
479 call assert_equal('3 cc', getline('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
480 normal zc
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
481 call assert_equal('1 aa', getline(foldclosed('.')))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
482
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
483 set fdm&
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
484 enew!
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
485 endfunc
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
486
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
487 " test folding with markers.
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
488 func Test_fold_marker()
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
489 enew!
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
490 set fdm=marker fdl=1 fdc=3
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
491
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
492 let content = ['4 dd {{{', '5 ee {{{ }}}', '6 ff }}}']
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
493 call append(0, content)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
494 call cursor(2, 1)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
495 call assert_equal(2, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
496 normal [z
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
497 call assert_equal(1, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
498 exe "normal jo{{ \<Esc>r{jj"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
499 call assert_equal(1, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
500 normal kYpj
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
501 call assert_equal(0, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
502
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
503 set fdm& fdl& fdc&
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
504 enew!
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
505 endfunc
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
506
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
507 " test folding with indent
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
508 func Test_fold_indent()
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
509 enew!
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
510 set fdm=indent sw=2
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
511
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
512 let content = ['1 aa', '2 bb', '3 cc']
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
513 call append(0, content)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
514 call cursor(2, 1)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
515 exe "normal i \<Esc>jI "
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
516 call assert_equal(2, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
517 normal k
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
518 call assert_equal(1, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
519
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
520 set fdm& sw&
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
521 enew!
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
522 endfunc
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
523
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
524 " test syntax folding
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
525 func Test_fold_syntax()
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
526 if !has('syntax')
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
527 return
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
528 endif
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
529
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
530 enew!
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
531 set fdm=syntax fdl=0
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
532
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
533 syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
534 syn region Fd1 start="ee" end="ff" fold contained
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
535 syn region Fd2 start="gg" end="hh" fold contained
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
536 syn region Fd3 start="commentstart" end="commentend" fold contained
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
537 let content = ['3 cc', '4 dd {{{', '5 ee {{{ }}}', '{{{{', '6 ff }}}',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
538 \ '6 ff }}}', '7 gg', '8 hh', '9 ii']
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
539 call append(0, content)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
540 normal Gzk
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
541 call assert_equal('9 ii', getline('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
542 normal k
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
543 call assert_equal('3 cc', getline('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
544 exe "normal jAcommentstart \<Esc>Acommentend"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
545 set fdl=1
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
546 normal 3j
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
547 call assert_equal('7 gg', getline('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
548 set fdl=0
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
549 exe "normal zO\<C-L>j"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
550 call assert_equal('8 hh', getline('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
551 syn clear Fd1 Fd2 Fd3 Hup
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
552
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
553 set fdm& fdl&
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
554 enew!
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
555 endfunc
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
556
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
557 func Flvl()
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
558 let l = getline(v:lnum)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
559 if l =~ "bb$"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
560 return 2
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
561 elseif l =~ "gg$"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
562 return "s1"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
563 elseif l =~ "ii$"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
564 return ">2"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
565 elseif l =~ "kk$"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
566 return "0"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
567 endif
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
568 return "="
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
569 endfun
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
570
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
571 " test expression folding
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
572 func Test_fold_expr()
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
573 enew!
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
574 set fdm=expr fde=Flvl()
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
575
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
576 let content = ['1 aa',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
577 \ '2 bb',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
578 \ '3 cc',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
579 \ '4 dd {{{commentstart commentend',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
580 \ '5 ee {{{ }}}',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
581 \ '{{{',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
582 \ '6 ff }}}',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
583 \ '6 ff }}}',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
584 \ ' 7 gg',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
585 \ ' 8 hh',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
586 \ '9 ii',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
587 \ 'a jj',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
588 \ 'b kk']
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
589 call append(0, content)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
590 call cursor(1, 1)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
591 exe "normal /bb$\<CR>"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
592 call assert_equal(2, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
593 exe "normal /hh$\<CR>"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
594 call assert_equal(1, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
595 exe "normal /ii$\<CR>"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
596 call assert_equal(2, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
597 exe "normal /kk$\<CR>"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
598 call assert_equal(0, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
599
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
600 set fdm& fde&
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
601 enew!
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
602 endfunc
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
603
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
604 " Bug with fdm=indent and moving folds
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
605 " Moving a fold a few times, messes up the folds below the moved fold.
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
606 " Fixed by 7.4.700
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
607 func Test_fold_move()
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
608 enew!
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
609 set fdm=indent sw=2 fdl=0
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
610
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
611 let content = ['', '', 'Line1', ' Line2', ' Line3',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
612 \ 'Line4', ' Line5', ' Line6',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
613 \ 'Line7', ' Line8', ' Line9']
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
614 call append(0, content)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
615 normal zM
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
616 call cursor(4, 1)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
617 move 2
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
618 move 1
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
619 call assert_equal(7, foldclosed(7))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
620 call assert_equal(8, foldclosedend(7))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
621 call assert_equal(0, foldlevel(9))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
622 call assert_equal(10, foldclosed(10))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
623 call assert_equal(11, foldclosedend(10))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
624 call assert_equal('+-- 2 lines: Line2', foldtextresult(2))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
625 call assert_equal('+-- 2 lines: Line8', foldtextresult(10))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
626
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
627 set fdm& sw& fdl&
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
628 enew!
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
629 endfunc