annotate src/testdir/test_fold.vim @ 11038:c8b49300c6b7 v8.0.0408

patch 8.0.0408: updating folds does not always work properly commit https://github.com/vim/vim/commit/eadbc2b46176e2aff2cde5f3874b734ae2ae082a Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 4 18:42:39 2017 +0100 patch 8.0.0408: updating folds does not always work properly Problem: Updating folds does not work properly when inserting a file and a few other situations. Solution: Adjust the way folds are updated. (Matthew Malcomson)
author Christian Brabandt <cb@256bit.org>
date Sat, 04 Mar 2017 18:45:04 +0100
parents 9861e4196c43
children 8d9ecf09183a
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
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
3 func! Test_address_fold()
10484
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 new
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 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
6 \ '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
7 setl fen fdm=marker
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 " The next ccommands should all copy the same part of the buffer,
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 " regardless of the adressing type, since the part to be copied
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 " is folded away
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 :1y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 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
13 :.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 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
15 :.+y
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 :sil .1,.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 " use silent to make E493 go away
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 :sil .+,.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 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
24 :,y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 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
26 :,+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', '}/*}}}*/','after fold 1'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 " 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
29 " lines
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 :.,+3y
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', '}/*}}}*/',
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 \ '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
33 :sil .,-2y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 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
35
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 " now test again with folding disabled
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 set nofoldenable
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 :1y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 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
40 :.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 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
42 :.+y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 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
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 " use silent to make E493 go away
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 :sil .1,.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 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
49 " use silent to make E493 go away
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 :sil .+,.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 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
52 :,y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 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
54 :,+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 " 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
57 " lines
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 :.,+3y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 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
60 :7
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 :sil .,-2y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 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
63
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 quit!
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
65 endfunc
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
66
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
67 func! Test_indent_fold()
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
68 new
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
69 call setline(1, ['', 'a', ' b', ' c'])
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
70 setl fen fdm=indent
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
71 2
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
72 norm! >>
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
73 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
74 call assert_equal([-1,-1,-1,-1], a)
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
75 endfunc
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
76
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
77 func! Test_indent_fold()
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
78 new
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
79 call setline(1, ['', 'a', ' b', ' c'])
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
80 setl fen fdm=indent
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
81 2
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
82 norm! >>
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
83 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
84 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
85 bw!
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
86 endfunc
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
87
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
88 func! Test_indent_fold2()
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
89 new
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
90 call setline(1, ['', '{{{', '}}}', '{{{', '}}}'])
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
91 setl fen fdm=marker
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
92 2
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
93 norm! >>
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
94 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
95 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
96 bw!
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
97 endfunc
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
98
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
99 func Test_manual_fold_with_filter()
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
100 if !executable('cat')
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
101 return
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
102 endif
11036
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
103 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
104 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
105 new
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
106 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
107 4,$fold
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
108 %foldopen
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
109 10,$fold
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
110 %foldopen
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
111 " 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
112 1,8! cat
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
113 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
114 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
115
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
116 bwipe!
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
117 set foldmethod&
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
118 endfor
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
119 endfunc
11038
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
120
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
121 func! Test_indent_fold_with_read()
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
122 new
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
123 set foldmethod=indent
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
124 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
125 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
126 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
127 endfor
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
128
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
129 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
130 foldopen
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
131 2read Xfile
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
132 %foldclose
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
133 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
134 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
135 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
136 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
137 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
138 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
139
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
140 bwipe!
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
141 set foldmethod&
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
142 call delete('Xfile')
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
143 endfunc
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
144
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
145 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
146 new
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
147 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
148 let zero = 'a'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
149 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
150 set foldmethod=indent
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
151 3,5d
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
152 %foldclose
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
153 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
154
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
155 set foldmethod&
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
156 bwipe!
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
157 endfunc
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
158
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
159 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
160 new
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
161 call setline(1, ['{{{', '}}}', '', '', '', '{{{', '', '}}}'])
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
162 set foldmethod=marker
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
163 3,5d
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
164 %foldclose
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
165 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
166
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
167 set foldmethod&
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
168 bwipe!
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
169 endfunc
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
170
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
171 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
172 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
173 if thisline == 'a'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
174 return 1
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
175 elseif thisline == 'b'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
176 return 0
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
177 elseif thisline == 'c'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
178 return '<1'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
179 elseif thisline == 'd'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
180 return '>1'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
181 endif
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
182 return 0
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
183 endfunction
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
184
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
185 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
186 new
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
187 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
188 set foldmethod=expr
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
189 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
190 2
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
191 foldopen
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
192 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
193 read Xfile
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
194 %foldclose
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
195 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
196 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
197 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
198 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
199 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
200 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
201
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
202 call delete('Xfile')
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
203 bwipe!
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
204 set foldmethod& foldexpr&
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
205 endfunc