Mercurial > vim
annotate src/testdir/test_fold.vim @ 11993:92a86fe8adc0 v8.0.0877
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
commit https://github.com/vim/vim/commit/6d8197485dc84532e37aced2c39292bff374200d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 6 14:57:49 2017 +0200
patch 8.0.0877: using CTRL-\ CTRL-N in terminal is inconsistent
Problem: Using CTRL-\ CTRL-N in terminal is inconsistent.
Solution: Stay in Normal mode.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 06 Aug 2017 15:00:04 +0200 |
parents | dc2800c3572b |
children | f6534b99b76f |
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)')) |
11156
80241603dd50
patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents:
11140
diff
changeset
|
281 %d |
80241603dd50
patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents:
11140
diff
changeset
|
282 " 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
|
283 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
|
284 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
|
285 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
|
286 %foldopen |
80241603dd50
patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents:
11140
diff
changeset
|
287 6m$ |
80241603dd50
patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents:
11140
diff
changeset
|
288 " 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
|
289 " 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
|
290 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
|
291 |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
292 %delete |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
293 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
|
294 call setline(1, [ |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
295 \ "a", |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
296 \ "\ta", |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
297 \ "\t\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 \ "a", |
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 set fdm=manual |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
303 %foldopen! |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
304 4,5m6 |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
305 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
|
306 |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
307 %delete |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
308 set fdm=indent |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
309 call setline(1, [ |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
310 \ "\ta", |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
311 \ "\t\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 \ "\ta", |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
315 \ "\t\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 \ "\ta", |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
319 \ "\t\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 \ "\ta", |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
324 \ "a"]) |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
325 set fdm=manual |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
326 %foldopen! |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
327 13m7 |
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
328 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
|
329 |
11140
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
330 bw! |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
331 endfunc |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
332 |
11392
dc2800c3572b
patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents:
11219
diff
changeset
|
333 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
|
334 new |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
335 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
|
336 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
|
337 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
|
338 " all folds closed |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
339 set fdm=indent |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
340 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
|
341 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
|
342 7,12m0 |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
343 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
|
344 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
|
345 10,12m0 |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
346 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
|
347 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
|
348 " 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
|
349 %d |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
350 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
|
351 set fdm=indent |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
352 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
|
353 %foldopen |
11140
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
354 7,12m0 |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
355 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
|
356 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
|
357 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
|
358 norm! zM |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
359 " 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
|
360 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
|
361 %d |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
362 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
|
363 set fdm=indent |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
364 %foldopen |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
365 3m4 |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
366 %foldclose |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
367 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
|
368 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
|
369 %d |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
370 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
|
371 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
|
372 %foldopen |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
373 3m1 |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
374 %foldclose |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
375 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
|
376 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
|
377 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
|
378 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
|
379 2,6m$ |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
380 %foldclose |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
381 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
|
382 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
|
383 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
|
384 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
|
385 " 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
|
386 %d |
80241603dd50
patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents:
11140
diff
changeset
|
387 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
|
388 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
|
389 %foldopen |
80241603dd50
patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents:
11140
diff
changeset
|
390 6m$ |
80241603dd50
patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents:
11140
diff
changeset
|
391 " 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
|
392 " 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
|
393 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
|
394 bw! |
6b26e044b6f5
patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents:
11131
diff
changeset
|
395 endfunc |
11219
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
396 |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
397 func Test_folddoopen_folddoclosed() |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
398 new |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
399 call setline(1, range(1, 9)) |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
400 set foldmethod=manual |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
401 1,3 fold |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
402 6,8 fold |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
403 |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
404 " Test without range. |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
405 folddoopen s/$/o/ |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
406 folddoclosed s/$/c/ |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
407 call assert_equal(['1c', '2c', '3c', |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
408 \ '4o', '5o', |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
409 \ '6c', '7c', '8c', |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
410 \ '9o'], getline(1, '$')) |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
411 |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
412 " Test with range. |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
413 call setline(1, range(1, 9)) |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
414 1,8 folddoopen s/$/o/ |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
415 4,$ folddoclosed s/$/c/ |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
416 call assert_equal(['1', '2', '3', |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
417 \ '4o', '5o', |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
418 \ '6c', '7c', '8c', |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
419 \ '9'], getline(1, '$')) |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
420 |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
421 set foldmethod& |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
422 bw! |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
423 endfunc |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
424 |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
425 func Test_fold_error() |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
426 new |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
427 call setline(1, [1, 2]) |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
428 |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
429 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
|
430 exe 'set foldmethod=' . fm |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
431 call assert_fails('norm zf', 'E350:') |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
432 call assert_fails('norm zd', 'E351:') |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
433 call assert_fails('norm zE', 'E352:') |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
434 endfor |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
435 |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
436 set foldmethod=manual |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
437 call assert_fails('norm zd', 'E490:') |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
438 call assert_fails('norm zo', 'E490:') |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
439 call assert_fails('3fold', 'E16:') |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
440 |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
441 set foldmethod=marker |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
442 set nomodifiable |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
443 call assert_fails('1,2fold', 'E21:') |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
444 |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
445 set modifiable& |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
446 set foldmethod& |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
447 bw! |
e53609585b76
patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents:
11156
diff
changeset
|
448 endfunc |