annotate src/testdir/test_fold.vim @ 35157:c3d7b6a450c0 default tip

translation(it): update translation of xxd manpage Commit: https://github.com/vim/vim/commit/9e4bfb219f606502f789a460f090b6bf1cf70b97 Author: Antonio Giovanni Colombo <azc100@gmail.com> Date: Fri May 10 23:51:30 2024 +0200 translation(it): update translation of xxd manpage Signed-off-by: Antonio Giovanni Colombo <azc100@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 11 May 2024 00:00:04 +0200
parents 48955338edb1
children
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
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
3 source check.vim
14317
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
4 source view_util.vim
14875
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
5 source screendump.vim
14317
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
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 PrepIndent(arg)
11140
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
8 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
9 endfu
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
10
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
11 func Test_address_fold()
10484
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 new
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 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
14 \ '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
15 setl fen fdm=marker
11219
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
16 " 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
17 " 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
18 " is folded away
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 :1y
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 :.+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 :.,.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 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
27 :sil .1,.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 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
29 " use silent to make E493 go away
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 :sil .+,.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', '}/*}}}*/'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 :,y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 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
34 :,+y
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', '}/*}}}*/','after fold 1'], getreg(0,1,1))
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 " 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
37 " lines
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 :.,+3y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 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
40 \ '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
41 :sil .,-2y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 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
43
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 " now test again with folding disabled
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 set nofoldenable
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 :1y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 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
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 :.+y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 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
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 " use silent to make E493 go away
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 :sil .1,.y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 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
57 " use silent to make E493 go away
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 :sil .+,.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 :,y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 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
62 :,+y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 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
64 " 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
65 " lines
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 :.,+3y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 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
68 :7
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 :sil .,-2y
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 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
71
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 quit!
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
73 endfunc
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
74
31053
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
75 func Test_address_offsets()
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
76 " check the help for :range-closed-fold
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
77 enew
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
78 call setline(1, [
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
79 \ '1 one',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
80 \ '2 two',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
81 \ '3 three',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
82 \ '4 four FOLDED',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
83 \ '5 five FOLDED',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
84 \ '6 six',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
85 \ '7 seven',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
86 \ '8 eight',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
87 \])
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
88 set foldmethod=manual
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
89 normal 4Gvjzf
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
90 3,4+2yank
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
91 call assert_equal([
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
92 \ '3 three',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
93 \ '4 four FOLDED',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
94 \ '5 five FOLDED',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
95 \ '6 six',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
96 \ '7 seven',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
97 \ ], getreg(0,1,1))
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
98
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
99 enew!
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
100 call setline(1, [
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
101 \ '1 one',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
102 \ '2 two',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
103 \ '3 three FOLDED',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
104 \ '4 four FOLDED',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
105 \ '5 five FOLDED',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
106 \ '6 six FOLDED',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
107 \ '7 seven',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
108 \ '8 eight',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
109 \])
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
110 normal 3Gv3jzf
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
111 2,4-1yank
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
112 call assert_equal([
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
113 \ '2 two',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
114 \ '3 three FOLDED',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
115 \ '4 four FOLDED',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
116 \ '5 five FOLDED',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
117 \ '6 six FOLDED',
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
118 \ ], getreg(0,1,1))
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
119
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
120 bwipe!
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
121 endfunc
39f96b1e7b8d patch 9.0.0861: solution for "!!sort" in closed fold is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 31047
diff changeset
122
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
123 func Test_indent_fold()
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
124 new
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
125 call setline(1, ['', 'a', ' b', ' c'])
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
126 setl fen fdm=indent
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
127 2
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
128 norm! >>
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
129 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
130 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
131 bw!
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
132 endfunc
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
133
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
134 func Test_indent_fold2()
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
135 new
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
136 call setline(1, ['', '{{{', '}}}', '{{{', '}}}'])
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
137 setl fen fdm=marker
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
138 2
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
139 norm! >>
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17787
diff changeset
140 let a=map(range(1,5), 'v:val->foldclosed()')
10486
99896ee0cac5 commit https://github.com/vim/vim/commit/54b2bfa399017ebae76ed62f21578261d1b55c1f
Christian Brabandt <cb@256bit.org>
parents: 10484
diff changeset
141 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
142 bw!
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
143 endfunc
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
144
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
145 " Test for fold indent with indents greater than 'foldnestmax'
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
146 func Test_indent_fold_max()
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
147 new
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
148 setlocal foldmethod=indent
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
149 setlocal shiftwidth=2
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
150 " 'foldnestmax' default value is 20
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
151 call setline(1, "\t\t\t\t\t\ta")
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
152 call assert_equal(20, foldlevel(1))
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
153 setlocal foldnestmax=10
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
154 call assert_equal(10, foldlevel(1))
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
155 setlocal foldnestmax=-1
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
156 call assert_equal(0, foldlevel(1))
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
157 bw!
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
158 endfunc
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
159
31491
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
160 func Test_indent_fold_tabstop()
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
161 call setline(1, ['0', ' 1', ' 1', "\t2", "\t2"])
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
162 setlocal shiftwidth=4
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
163 setlocal foldcolumn=1
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
164 setlocal foldlevel=2
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
165 setlocal foldmethod=indent
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
166 redraw
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
167 call assert_equal('2 2', ScreenLines(5, 10)[0])
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
168 vsplit
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
169 windo diffthis
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
170 botright new
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
171 " This 'tabstop' value should not be used for folding in other buffers.
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
172 setlocal tabstop=4
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
173 diffoff!
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
174 redraw
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
175 call assert_equal('2 2', ScreenLines(5, 10)[0])
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
176
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
177 bwipe!
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
178 bwipe!
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
179 endfunc
6d42026ad002 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 31053
diff changeset
180
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
181 func Test_manual_fold_with_filter()
23027
f74978697fb6 patch 8.2.2060: check for features implemented with "if"
Bram Moolenaar <Bram@vim.org>
parents: 22850
diff changeset
182 CheckExecutable cat
11036
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
183 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
184 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
185 new
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
186 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
187 4,$fold
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
188 %foldopen
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
189 10,$fold
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
190 %foldopen
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
191 " 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
192 1,8! cat
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
193 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
194 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
195
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
196 bwipe!
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
197 set foldmethod&
9861e4196c43 patch 8.0.0407: filtering folds with marker method not tested
Christian Brabandt <cb@256bit.org>
parents: 10998
diff changeset
198 endfor
10998
2645a98217fa patch 8.0.0388: filtering lines changes folds
Christian Brabandt <cb@256bit.org>
parents: 10486
diff changeset
199 endfunc
11038
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
200
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
201 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
202 new
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
203 set foldmethod=indent
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
204 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
205 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
206 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
207 endfor
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
208
30552
a7a9e8b9af89 patch 9.0.0611: tests delete files with a separate delete() call
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
209 call writefile(["a", "", "\<Tab>a"], 'Xinfofile', 'D')
11038
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
210 foldopen
30051
13b02c1ea0f7 patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents: 29320
diff changeset
211 2read Xinfofile
11038
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
212 %foldclose
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
213 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
214 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
215 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
216 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
217 call assert_equal(1, foldlevel(5))
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17787
diff changeset
218 call assert_equal(7, 5->foldclosedend())
11038
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
219
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
220 bwipe!
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
221 set foldmethod&
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
222 endfunc
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
223
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
224 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
225 new
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
226 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
227 let zero = 'a'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
228 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
229 set foldmethod=indent
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
230 3,5d
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
231 %foldclose
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
232 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
233
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
234 set foldmethod&
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
235 bwipe!
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
236 endfunc
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
237
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
238 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
239 new
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
240 call setline(1, ['{{{', '}}}', '', '', '', '{{{', '', '}}}'])
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
241 set foldmethod=marker
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
242 3,5d
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
243 %foldclose
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
244 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
245
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
246 set foldmethod&
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
247 bwipe!
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
248 endfunc
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
249
11131
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
250 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
251 new
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
252 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
253 setl fen fdm=marker
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
254 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
255 norm! zf2j
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
256 setl nofen
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
257 :1y
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
258 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
259 :+2y
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
260 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
261
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
262 set foldmethod&
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
263 bwipe!
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
264 endfunc
8d9ecf09183a patch 8.0.0453: adding fold marker creates new comment
Christian Brabandt <cb@256bit.org>
parents: 11038
diff changeset
265
11038
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
266 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
267 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
268 if thisline == 'a'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
269 return 1
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
270 elseif thisline == 'b'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
271 return 0
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
272 elseif thisline == 'c'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
273 return '<1'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
274 elseif thisline == 'd'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
275 return '>1'
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
276 endif
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
277 return 0
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
278 endfunction
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
279
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
280 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
281 new
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
282 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
283 set foldmethod=expr
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
284 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
285 2
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
286 foldopen
30552
a7a9e8b9af89 patch 9.0.0611: tests delete files with a separate delete() call
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
287 call writefile(['b', 'b', 'a', 'a', 'd', 'a', 'a', 'c'], 'Xupfofile', 'D')
30051
13b02c1ea0f7 patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents: 29320
diff changeset
288 read Xupfofile
11038
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
289 %foldclose
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
290 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
291 call assert_equal(0, foldlevel(3))
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17787
diff changeset
292 call assert_equal(0, 4->foldlevel())
11038
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
293 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
294 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
295 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
296
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
297 bwipe!
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
298 set foldmethod& foldexpr&
c8b49300c6b7 patch 8.0.0408: updating folds does not always work properly
Christian Brabandt <cb@256bit.org>
parents: 11036
diff changeset
299 endfunc
11140
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
300
28938
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
301 " Test for what patch 8.1.0535 fixes.
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
302 func Test_foldexpr_no_interrupt_addsub()
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
303 new
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
304 func! FoldFunc()
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
305 call setpos('.', getcurpos())
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
306 return '='
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
307 endfunc
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
308
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
309 set foldmethod=expr
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
310 set foldexpr=FoldFunc()
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
311 call setline(1, '1.2')
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
312
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
313 exe "norm! $\<C-A>"
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
314 call assert_equal('1.3', getline(1))
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
315
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
316 bwipe!
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
317 delfunc FoldFunc
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
318 set foldmethod& foldexpr&
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
319 endfunc
ddbb36c1830b patch 8.2.4991: no test for hwat patch 8.1.0535 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28929
diff changeset
320
30594
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
321 " Fold function defined in another script
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
322 func Test_foldexpr_compiled()
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
323 new
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
324 let lines =<< trim END
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
325 vim9script
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
326 def FoldFunc(): number
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
327 return v:lnum
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
328 enddef
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
329
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
330 set foldmethod=expr
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
331 set foldexpr=s:FoldFunc()
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
332 END
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
333 call writefile(lines, 'XfoldExpr', 'D')
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
334 source XfoldExpr
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
335
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
336 call setline(1, ['one', 'two', 'three'])
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
337 redraw
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
338 call assert_equal(1, foldlevel(1))
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
339 call assert_equal(2, foldlevel(2))
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
340 call assert_equal(3, foldlevel(3))
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
341
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
342 bwipe!
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
343 set foldmethod& foldexpr&
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
344 endfunc
586b5b3aacf9 patch 9.0.0632: calling a function from an "expr" option has overhead
Bram Moolenaar <Bram@vim.org>
parents: 30552
diff changeset
345
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
346 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
347 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
348 endfunc
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
349
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
350 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
351 new
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
352 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
353 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
354 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
355 " all folds closed
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
356 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
357 " needs a forced redraw
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
358 redraw!
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
359 set fdm=manual
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
360 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
361 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
362 7,12m0
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
363 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
364 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
365 10,12m0
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
366 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
367 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
368 " 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
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, 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
371 set fdm=indent
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
372 redraw!
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
373 set fdm=manual
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
374 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
375 %foldopen
11140
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
376 7,12m0
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
377 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
378 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
379 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
380 norm! zM
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
381 " 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
382 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
383 %d
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
384 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
385 set fdm=indent
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
386 redraw!
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
387 set fdm=manual
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
388 %foldopen
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
389 3m4
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
390 %foldclose
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
391 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
392 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
393 %d
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
394 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
395 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
396 set fdm=manual
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
397 %foldopen
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
398 3m1
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
399 %foldclose
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
400 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
401 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
402 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
403 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
404 2,6m$
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
405 %foldclose
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
406 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
407 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
408 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
409 call assert_equal([-1, 2, 2, 2, 2, -1, 7, 7, 7, -1], map(range(1, line('$')), 'foldclosed(v:val)'))
12471
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
410
11156
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
411 %d
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
412 " 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
413 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
414 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
415 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
416 %foldopen
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
417 6m$
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
418 " 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
419 " 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
420 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
421
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
422 %delete
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
423 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
424 call setline(1, [
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
425 \ "a",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
426 \ "\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
427 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
428 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
429 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
430 \ "a",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
431 \ "a"])
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
432 set fdm=manual
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
433 %foldopen!
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
434 4,5m6
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
435 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
436
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
437 %delete
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
438 set fdm=indent
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
439 call setline(1, [
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
440 \ "\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
441 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
442 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
443 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
444 \ "\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
445 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
446 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
447 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
448 \ "\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
449 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
450 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
451 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
452 \ "\t\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
453 \ "\ta",
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
454 \ "a"])
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
455 set fdm=manual
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
456 %foldopen!
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
457 13m7
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
458 call Check_foldlevels([1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 0])
31849
dbec60b8c253 patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents: 31821
diff changeset
459
11140
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
460 bw!
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
461 endfunc
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
462
11392
dc2800c3572b patch 8.0.0581: moving folded text is sometimes not correct
Christian Brabandt <cb@256bit.org>
parents: 11219
diff changeset
463 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
464 new
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
465 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
466 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
467 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
468 " all folds closed
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
469 set fdm=indent
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
470 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
471 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
472 7,12m0
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
473 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
474 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
475 10,12m0
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
476 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
477 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
478 " 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
479 %d
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
480 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
481 set fdm=indent
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
482 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
483 %foldopen
11140
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
484 7,12m0
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
485 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
486 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
487 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
488 norm! zM
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
489 " 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
490 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
491 %d
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
492 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
493 set fdm=indent
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
494 %foldopen
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
495 3m4
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
496 %foldclose
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
497 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
498 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
499 %d
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
500 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
501 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
502 %foldopen
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
503 3m1
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
504 %foldclose
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
505 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
506 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
507 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
508 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
509 2,6m$
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
510 %foldclose
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
511 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
512 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
513 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
514 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
515 " 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
516 %d
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
517 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
518 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
519 %foldopen
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
520 6m$
80241603dd50 patch 8.0.0465: off-by-one error in using :move with folding
Christian Brabandt <cb@256bit.org>
parents: 11140
diff changeset
521 " 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
522 " 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
523 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
524 bw!
6b26e044b6f5 patch 8.0.0457: using :move messes up manual folds
Christian Brabandt <cb@256bit.org>
parents: 11131
diff changeset
525 endfunc
11219
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
526
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
527 func Test_folddoopen_folddoclosed()
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
528 new
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
529 call setline(1, range(1, 9))
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
530 set foldmethod=manual
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
531 1,3 fold
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
532 6,8 fold
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
533
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
534 " Test without range.
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
535 folddoopen s/$/o/
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
536 folddoclosed s/$/c/
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
537 call assert_equal(['1c', '2c', '3c',
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
538 \ '4o', '5o',
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
539 \ '6c', '7c', '8c',
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
540 \ '9o'], getline(1, '$'))
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
541
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
542 " Test with range.
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
543 call setline(1, range(1, 9))
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
544 1,8 folddoopen s/$/o/
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
545 4,$ folddoclosed s/$/c/
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
546 call assert_equal(['1', '2', '3',
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
547 \ '4o', '5o',
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
548 \ '6c', '7c', '8c',
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
549 \ '9'], getline(1, '$'))
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
550
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
551 set foldmethod&
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
552 bw!
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
553 endfunc
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
554
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
555 func Test_fold_error()
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
556 new
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
557 call setline(1, [1, 2])
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
558
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
559 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
560 exe 'set foldmethod=' . fm
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
561 call assert_fails('norm zf', 'E350:')
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
562 call assert_fails('norm zd', 'E351:')
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
563 call assert_fails('norm zE', 'E352:')
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
564 endfor
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
565
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
566 set foldmethod=manual
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
567 call assert_fails('norm zd', 'E490:')
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
568 call assert_fails('norm zo', 'E490:')
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
569 call assert_fails('3fold', 'E16:')
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
570
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
571 set foldmethod=marker
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
572 set nomodifiable
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
573 call assert_fails('1,2fold', 'E21:')
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
574
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
575 set modifiable&
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
576 set foldmethod&
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
577 bw!
e53609585b76 patch 8.0.0496: insufficient testing for folding
Christian Brabandt <cb@256bit.org>
parents: 11156
diff changeset
578 endfunc
12471
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
579
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
580 func Test_foldtext_recursive()
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
581 new
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
582 call setline(1, ['{{{', 'some text', '}}}'])
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
583 setlocal foldenable foldmethod=marker foldtext=foldtextresult(v\:foldstart)
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
584 " This was crashing because of endless recursion.
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
585 2foldclose
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
586 redraw
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
587 call assert_equal(1, foldlevel(2))
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
588 call assert_equal(1, foldclosed(2))
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
589 call assert_equal(3, foldclosedend(2))
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
590 bwipe!
f6534b99b76f patch 8.0.1115: crash when using foldtextresult() recursively
Christian Brabandt <cb@256bit.org>
parents: 11392
diff changeset
591 endfunc
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
592
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
593 " Various fold related tests
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
594
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
595 " Basic test if a fold can be created, opened, moving to the end and closed
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
596 func Test_fold_manual()
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
597 new
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
598 set fdm=manual
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
599
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
600 let content = ['1 aa', '2 bb', '3 cc']
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
601 call append(0, content)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
602 call cursor(1, 1)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
603 normal zf2j
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
604 call assert_equal('1 aa', getline(foldclosed('.')))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
605 normal zo
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
606 call assert_equal(-1, foldclosed('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
607 normal ]z
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
608 call assert_equal('3 cc', getline('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
609 normal zc
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
610 call assert_equal('1 aa', getline(foldclosed('.')))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
611
24345
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
612 " Create a fold inside a closed fold after setting 'foldlevel'
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
613 %d _
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
614 call setline(1, range(1, 5))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
615 1,5fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
616 normal zR
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
617 2,4fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
618 set foldlevel=1
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
619 3fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
620 call assert_equal([1, 3, 3, 3, 1], map(range(1, 5), {->foldlevel(v:val)}))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
621 set foldlevel&
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
622
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
623 " Create overlapping folds (at the start and at the end)
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
624 normal zE
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
625 2,3fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
626 normal zR
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
627 3,4fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
628 call assert_equal([0, 2, 2, 1, 0], map(range(1, 5), {->foldlevel(v:val)}))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
629 normal zE
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
630 3,4fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
631 normal zR
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
632 2,3fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
633 call assert_equal([0, 1, 2, 2, 0], map(range(1, 5), {->foldlevel(v:val)}))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
634
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
635 " Create a nested fold across two non-adjoining folds
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
636 %d _
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
637 call setline(1, range(1, 7))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
638 1,2fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
639 normal zR
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
640 4,5fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
641 normal zR
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
642 6,7fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
643 normal zR
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
644 1,5fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
645 call assert_equal([2, 2, 1, 2, 2, 1, 1],
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
646 \ map(range(1, 7), {->foldlevel(v:val)}))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
647
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
648 " A newly created nested fold should be closed
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
649 %d _
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
650 call setline(1, range(1, 6))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
651 1,6fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
652 normal zR
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
653 3,4fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
654 normal zR
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
655 2,5fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
656 call assert_equal([1, 2, 3, 3, 2, 1], map(range(1, 6), {->foldlevel(v:val)}))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
657 call assert_equal(2, foldclosed(4))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
658 call assert_equal(5, foldclosedend(4))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
659
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
660 " Test zO, zC and zA on a line with no folds.
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
661 normal zE
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
662 call assert_fails('normal zO', 'E490:')
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
663 call assert_fails('normal zC', 'E490:')
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
664 call assert_fails('normal zA', 'E490:')
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
665
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
666 set fdm&
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
667 bw!
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
668 endfunc
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
669
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
670 " test folding with markers.
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
671 func Test_fold_marker()
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
672 new
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
673 set fdm=marker fdl=1 fdc=3
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
674
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
675 let content = ['4 dd {{{', '5 ee {{{ }}}', '6 ff }}}']
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
676 call append(0, content)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
677 call cursor(2, 1)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
678 call assert_equal(2, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
679 normal [z
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
680 call assert_equal(1, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
681 exe "normal jo{{ \<Esc>r{jj"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
682 call assert_equal(1, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
683 normal kYpj
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
684 call assert_equal(0, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
685
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
686 " Use only closing fold marker (without and with a count)
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
687 set fdl&
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
688 %d _
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
689 call setline(1, ['one }}}', 'two'])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
690 call assert_equal([0, 0], [foldlevel(1), foldlevel(2)])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
691 %d _
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
692 call setline(1, ['one }}}4', 'two'])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
693 call assert_equal([4, 3], [foldlevel(1), foldlevel(2)])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
694
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
695 set fdm& fdl& fdc&
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
696 bw!
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
697 endfunc
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
698
15127
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
699 " test create fold markers with C filetype
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
700 func Test_fold_create_marker_in_C()
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
701 bw!
15127
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
702 set fdm=marker fdl=9
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
703 set filetype=c
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
704
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15127
diff changeset
705 let content =<< trim [CODE]
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15127
diff changeset
706 /*
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15127
diff changeset
707 * comment
31849
dbec60b8c253 patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents: 31821
diff changeset
708 *
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15127
diff changeset
709 *
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15127
diff changeset
710 */
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15127
diff changeset
711 int f(int* p) {
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15127
diff changeset
712 *p = 3;
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15127
diff changeset
713 return 0;
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15127
diff changeset
714 }
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15127
diff changeset
715 [CODE]
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 15127
diff changeset
716
15127
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
717 for c in range(len(content) - 1)
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
718 bw!
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
719 call append(0, content)
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
720 call cursor(c + 1, 1)
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
721 norm! zfG
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
722 call assert_equal(content[c] . (c < 4 ? '{{{' : '/*{{{*/'), getline(c + 1))
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
723 endfor
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
724
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
725 set fdm& fdl&
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
726 bw!
15127
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
727 endfunc
31a0127813cb patch 8.1.0574: 'commentstring' not used when adding fold marker in C
Bram Moolenaar <Bram@vim.org>
parents: 15119
diff changeset
728
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
729 " test folding with indent
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
730 func Test_fold_indent()
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
731 new
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
732 set fdm=indent sw=2
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
733
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
734 let content = ['1 aa', '2 bb', '3 cc']
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
735 call append(0, content)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
736 call cursor(2, 1)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
737 exe "normal i \<Esc>jI "
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
738 call assert_equal(2, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
739 normal k
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
740 call assert_equal(1, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
741
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
742 set fdm& sw&
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
743 bw!
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
744 endfunc
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
745
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
746 " test syntax folding
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
747 func Test_fold_syntax()
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20156
diff changeset
748 CheckFeature syntax
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
749
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
750 new
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
751 set fdm=syntax fdl=0
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
752
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
753 syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
754 syn region Fd1 start="ee" end="ff" fold contained
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
755 syn region Fd2 start="gg" end="hh" fold contained
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
756 syn region Fd3 start="commentstart" end="commentend" fold contained
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
757 let content = ['3 cc', '4 dd {{{', '5 ee {{{ }}}', '{{{{', '6 ff }}}',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
758 \ '6 ff }}}', '7 gg', '8 hh', '9 ii']
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
759 call append(0, content)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
760 normal Gzk
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
761 call assert_equal('9 ii', getline('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
762 normal k
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
763 call assert_equal('3 cc', getline('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
764 exe "normal jAcommentstart \<Esc>Acommentend"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
765 set fdl=1
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
766 normal 3j
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
767 call assert_equal('7 gg', getline('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
768 set fdl=0
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
769 exe "normal zO\<C-L>j"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
770 call assert_equal('8 hh', getline('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
771 syn clear Fd1 Fd2 Fd3 Hup
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
772
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
773 set fdm& fdl&
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
774 bw!
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
775 endfunc
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
776
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
777 func Flvl()
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
778 let l = getline(v:lnum)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
779 if l =~ "bb$"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
780 return 2
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
781 elseif l =~ "gg$"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
782 return "s1"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
783 elseif l =~ "ii$"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
784 return ">2"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
785 elseif l =~ "kk$"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
786 return "0"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
787 endif
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
788 return "="
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
789 endfun
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
790
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
791 " test expression folding
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
792 func Test_fold_expr()
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
793 new
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
794 set fdm=expr fde=Flvl()
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
795
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
796 let content = ['1 aa',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
797 \ '2 bb',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
798 \ '3 cc',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
799 \ '4 dd {{{commentstart commentend',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
800 \ '5 ee {{{ }}}',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
801 \ '{{{',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
802 \ '6 ff }}}',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
803 \ '6 ff }}}',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
804 \ ' 7 gg',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
805 \ ' 8 hh',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
806 \ '9 ii',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
807 \ 'a jj',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
808 \ 'b kk']
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
809 call append(0, content)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
810 call cursor(1, 1)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
811 exe "normal /bb$\<CR>"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
812 call assert_equal(2, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
813 exe "normal /hh$\<CR>"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
814 call assert_equal(1, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
815 exe "normal /ii$\<CR>"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
816 call assert_equal(2, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
817 exe "normal /kk$\<CR>"
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
818 call assert_equal(0, foldlevel('.'))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
819
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
820 set fdm& fde&
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
821 bw!
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
822 endfunc
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
823
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
824 " Bug with fdm=indent and moving folds
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
825 " Moving a fold a few times, messes up the folds below the moved fold.
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
826 " Fixed by 7.4.700
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
827 func Test_fold_move()
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
828 new
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
829 set fdm=indent sw=2 fdl=0
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
830
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
831 let content = ['', '', 'Line1', ' Line2', ' Line3',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
832 \ 'Line4', ' Line5', ' Line6',
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
833 \ 'Line7', ' Line8', ' Line9']
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
834 call append(0, content)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
835 normal zM
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
836 call cursor(4, 1)
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
837 move 2
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
838 move 1
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
839 call assert_equal(7, foldclosed(7))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
840 call assert_equal(8, foldclosedend(7))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
841 call assert_equal(0, foldlevel(9))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
842 call assert_equal(10, foldclosed(10))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
843 call assert_equal(11, foldclosedend(10))
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
844 call assert_equal('+-- 2 lines: Line2', foldtextresult(2))
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17787
diff changeset
845 call assert_equal('+-- 2 lines: Line8', 10->foldtextresult())
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
846
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
847 set fdm& sw& fdl&
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
848 bw!
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12471
diff changeset
849 endfunc
12788
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
850
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
851 " test for patch 7.3.637
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
852 " Cannot catch the error caused by a foldopen when there is no fold.
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
853 func Test_foldopen_exception()
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
854 new
12788
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
855 let a = 'No error caught'
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
856 try
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
857 foldopen
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
858 catch
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
859 let a = matchstr(v:exception,'^[^ ]*')
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
860 endtry
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
861 call assert_equal('Vim(foldopen):E490:', a)
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
862
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
863 let a = 'No error caught'
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
864 try
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
865 foobar
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
866 catch
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
867 let a = matchstr(v:exception,'^[^ ]*')
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
868 endtry
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
869 call assert_match('E492:', a)
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
870 bw!
12788
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
871 endfunc
14317
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
872
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
873 func Test_fold_last_line_with_pagedown()
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
874 new
14317
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
875 set fdm=manual
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
876
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
877 let expect = '+-- 11 lines: 9---'
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
878 let content = range(1,19)
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
879 call append(0, content)
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
880 normal dd9G
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
881 normal zfG
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
882 normal zt
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
883 call assert_equal('9', getline(foldclosed('.')))
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
884 call assert_equal('19', getline(foldclosedend('.')))
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
885 call assert_equal(expect, ScreenLines(1, len(expect))[0])
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
886 call feedkeys("\<C-F>", 'xt')
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
887 call assert_equal(expect, ScreenLines(1, len(expect))[0])
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
888 call feedkeys("\<C-F>", 'xt')
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
889 call assert_equal(expect, ScreenLines(1, len(expect))[0])
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
890 call feedkeys("\<C-B>\<C-F>\<C-F>", 'xt')
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
891 call assert_equal(expect, ScreenLines(1, len(expect))[0])
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
892
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
893 set fdm&
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
894 bw!
14317
1bc96dbb5498 patch 8.1.0174: after paging up and down fold line is wrong
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
895 endfunc
14875
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
896
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
897 func Test_folds_with_rnu()
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
898 CheckScreendump
14875
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
899
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
900 call writefile([
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
901 \ 'set fdm=marker rnu foldcolumn=2',
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
902 \ 'call setline(1, ["{{{1", "nline 1", "{{{1", "line 2"])',
30552
a7a9e8b9af89 patch 9.0.0611: tests delete files with a separate delete() call
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
903 \ ], 'Xtest_folds_with_rnu', 'D')
14875
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
904 let buf = RunVimInTerminal('-S Xtest_folds_with_rnu', {})
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
905
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
906 call VerifyScreenDump(buf, 'Test_folds_with_rnu_01', {})
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
907 call term_sendkeys(buf, "j")
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
908 call VerifyScreenDump(buf, 'Test_folds_with_rnu_02', {})
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
909
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
910 " clean up
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
911 call StopVimInTerminal(buf)
081f30c50300 patch 8.1.0449: when 'rnu' is set folded lines are not displayed correctly
Christian Brabandt <cb@256bit.org>
parents: 14317
diff changeset
912 endfunc
15119
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
913
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
914 func Test_folds_marker_in_comment2()
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
915 new
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
916 call setline(1, ['Lorem ipsum dolor sit', 'Lorem ipsum dolor sit', 'Lorem ipsum dolor sit'])
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
917 setl fen fdm=marker
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
918 setl commentstring=<!--%s-->
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
919 setl comments=s:<!--,m:\ \ \ \ ,e:-->
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
920 norm! zf2j
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
921 setl nofen
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
922 :1y
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
923 call assert_equal(['Lorem ipsum dolor sit<!--{{{-->'], getreg(0,1,1))
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
924 :+2y
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
925 call assert_equal(['Lorem ipsum dolor sit<!--}}}-->'], getreg(0,1,1))
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
926
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
927 set foldmethod&
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
928 bwipe!
6e9f37bf987b patch 8.1.0570: 'commentstring' not used when adding fold marker
Bram Moolenaar <Bram@vim.org>
parents: 14875
diff changeset
929 endfunc
17787
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
930
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
931 func Test_fold_delete_with_marker()
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
932 new
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
933 call setline(1, ['func Func() {{{1', 'endfunc'])
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
934 1,2yank
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
935 new
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
936 set fdm=marker
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
937 call setline(1, 'x')
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
938 normal! Vp
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
939 normal! zd
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
940 call assert_equal(['func Func() ', 'endfunc'], getline(1, '$'))
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
941
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
942 set fdm&
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
943 bwipe!
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
944 bwipe!
92e0996e1cb8 patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
945 endfunc
18114
90b0af9ba4ff patch 8.1.2052: using "x" before a closed fold may delete that fold
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
946
90b0af9ba4ff patch 8.1.2052: using "x" before a closed fold may delete that fold
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
947 func Test_fold_delete_with_marker_and_whichwrap()
90b0af9ba4ff patch 8.1.2052: using "x" before a closed fold may delete that fold
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
948 new
90b0af9ba4ff patch 8.1.2052: using "x" before a closed fold may delete that fold
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
949 let content1 = ['']
90b0af9ba4ff patch 8.1.2052: using "x" before a closed fold may delete that fold
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
950 let content2 = ['folded line 1 "{{{1', ' test', ' test2', ' test3', '', 'folded line 2 "{{{1', ' test', ' test2', ' test3']
90b0af9ba4ff patch 8.1.2052: using "x" before a closed fold may delete that fold
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
951 call setline(1, content1 + content2)
90b0af9ba4ff patch 8.1.2052: using "x" before a closed fold may delete that fold
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
952 set fdm=marker ww+=l
90b0af9ba4ff patch 8.1.2052: using "x" before a closed fold may delete that fold
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
953 normal! x
90b0af9ba4ff patch 8.1.2052: using "x" before a closed fold may delete that fold
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
954 call assert_equal(content2, getline(1, '$'))
90b0af9ba4ff patch 8.1.2052: using "x" before a closed fold may delete that fold
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
955 set fdm& ww&
90b0af9ba4ff patch 8.1.2052: using "x" before a closed fold may delete that fold
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
956 bwipe!
90b0af9ba4ff patch 8.1.2052: using "x" before a closed fold may delete that fold
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
957 endfunc
18882
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
958
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
959 func Test_fold_delete_first_line()
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
960 new
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
961 call setline(1, [
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
962 \ '" x {{{1',
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
963 \ '" a',
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
964 \ '" aa',
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
965 \ '" x {{{1',
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
966 \ '" b',
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
967 \ '" bb',
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
968 \ '" x {{{1',
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
969 \ '" c',
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
970 \ '" cc',
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
971 \ ])
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
972 set foldmethod=marker
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
973 1
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
974 normal dj
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
975 call assert_equal([
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
976 \ '" x {{{1',
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
977 \ '" c',
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
978 \ '" cc',
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
979 \ ], getline(1,'$'))
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
980 bwipe!
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
981 set foldmethod&
f9e41ffd3539 patch 8.2.0002: "dj" only deletes first line of closed fold
Bram Moolenaar <Bram@vim.org>
parents: 18114
diff changeset
982 endfunc
20156
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
983
24345
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
984 " Add a test for deleting the outer fold of a nested fold and promoting the
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
985 " inner folds to one level up with already a fold at that level following the
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
986 " nested fold.
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
987 func Test_fold_delete_recursive_fold()
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
988 new
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
989 call setline(1, range(1, 7))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
990 2,3fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
991 normal zR
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
992 4,5fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
993 normal zR
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
994 1,5fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
995 normal zR
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
996 6,7fold
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
997 normal zR
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
998 normal 1Gzd
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
999 normal 1Gzj
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1000 call assert_equal(2, line('.'))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1001 normal zj
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1002 call assert_equal(4, line('.'))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1003 normal zj
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1004 call assert_equal(6, line('.'))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1005 bw!
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1006 endfunc
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1007
20156
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1008 " Test for errors in 'foldexpr'
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1009 func Test_fold_expr_error()
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1010 new
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1011 call setline(1, ['one', 'two', 'three'])
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1012 " In a window with no folds, foldlevel() should return 0
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1013 call assert_equal(0, foldlevel(1))
20156
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1014
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1015 " Return a list from the expression
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1016 set foldexpr=[]
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1017 set foldmethod=expr
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1018 for i in range(3)
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1019 call assert_equal(0, foldlevel(i))
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1020 endfor
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1021
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1022 " expression error
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1023 set foldexpr=[{]
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1024 set foldmethod=expr
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1025 for i in range(3)
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1026 call assert_equal(0, foldlevel(i))
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1027 endfor
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1028
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1029 set foldmethod& foldexpr&
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1030 close!
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1031 endfunc
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1032
22306
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1033 func Test_undo_fold_deletion()
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1034 new
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1035 set fdm=marker
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1036 let lines =<< trim END
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1037 " {{{
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1038 " }}}1
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1039 " {{{
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1040 END
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1041 call setline(1, lines)
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1042 3d
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1043 g/"/d
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1044 undo
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1045 redo
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1046 eval getline(1, '$')->assert_equal([''])
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1047
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1048 set fdm&vim
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1049 bwipe!
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1050 endfunc
86696c617f70 patch 8.2.1702: crash when using undo after deleting folded lines
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1051
22798
3c72820f88b2 patch 8.2.1947: crash when using "zj" without folds
Bram Moolenaar <Bram@vim.org>
parents: 22306
diff changeset
1052 " this was crashing
3c72820f88b2 patch 8.2.1947: crash when using "zj" without folds
Bram Moolenaar <Bram@vim.org>
parents: 22306
diff changeset
1053 func Test_move_no_folds()
3c72820f88b2 patch 8.2.1947: crash when using "zj" without folds
Bram Moolenaar <Bram@vim.org>
parents: 22306
diff changeset
1054 new
3c72820f88b2 patch 8.2.1947: crash when using "zj" without folds
Bram Moolenaar <Bram@vim.org>
parents: 22306
diff changeset
1055 fold
3c72820f88b2 patch 8.2.1947: crash when using "zj" without folds
Bram Moolenaar <Bram@vim.org>
parents: 22306
diff changeset
1056 setlocal fdm=expr
3c72820f88b2 patch 8.2.1947: crash when using "zj" without folds
Bram Moolenaar <Bram@vim.org>
parents: 22306
diff changeset
1057 normal zj
3c72820f88b2 patch 8.2.1947: crash when using "zj" without folds
Bram Moolenaar <Bram@vim.org>
parents: 22306
diff changeset
1058 bwipe!
3c72820f88b2 patch 8.2.1947: crash when using "zj" without folds
Bram Moolenaar <Bram@vim.org>
parents: 22306
diff changeset
1059 endfunc
3c72820f88b2 patch 8.2.1947: crash when using "zj" without folds
Bram Moolenaar <Bram@vim.org>
parents: 22306
diff changeset
1060
22850
b05cfda397dc patch 8.2.1972: crash when recreating nested fold
Bram Moolenaar <Bram@vim.org>
parents: 22798
diff changeset
1061 " this was crashing
b05cfda397dc patch 8.2.1972: crash when recreating nested fold
Bram Moolenaar <Bram@vim.org>
parents: 22798
diff changeset
1062 func Test_fold_create_delete_create()
b05cfda397dc patch 8.2.1972: crash when recreating nested fold
Bram Moolenaar <Bram@vim.org>
parents: 22798
diff changeset
1063 new
b05cfda397dc patch 8.2.1972: crash when recreating nested fold
Bram Moolenaar <Bram@vim.org>
parents: 22798
diff changeset
1064 fold
b05cfda397dc patch 8.2.1972: crash when recreating nested fold
Bram Moolenaar <Bram@vim.org>
parents: 22798
diff changeset
1065 fold
b05cfda397dc patch 8.2.1972: crash when recreating nested fold
Bram Moolenaar <Bram@vim.org>
parents: 22798
diff changeset
1066 normal zd
b05cfda397dc patch 8.2.1972: crash when recreating nested fold
Bram Moolenaar <Bram@vim.org>
parents: 22798
diff changeset
1067 fold
b05cfda397dc patch 8.2.1972: crash when recreating nested fold
Bram Moolenaar <Bram@vim.org>
parents: 22798
diff changeset
1068 bwipe!
b05cfda397dc patch 8.2.1972: crash when recreating nested fold
Bram Moolenaar <Bram@vim.org>
parents: 22798
diff changeset
1069 endfunc
b05cfda397dc patch 8.2.1972: crash when recreating nested fold
Bram Moolenaar <Bram@vim.org>
parents: 22798
diff changeset
1070
23260
ef4f890f02f6 patch 8.2.2176: crash with a sequence of fold commands
Bram Moolenaar <Bram@vim.org>
parents: 23027
diff changeset
1071 " this was crashing
ef4f890f02f6 patch 8.2.2176: crash with a sequence of fold commands
Bram Moolenaar <Bram@vim.org>
parents: 23027
diff changeset
1072 func Test_fold_create_delete()
ef4f890f02f6 patch 8.2.2176: crash with a sequence of fold commands
Bram Moolenaar <Bram@vim.org>
parents: 23027
diff changeset
1073 new
ef4f890f02f6 patch 8.2.2176: crash with a sequence of fold commands
Bram Moolenaar <Bram@vim.org>
parents: 23027
diff changeset
1074 norm zFzFzdzj
ef4f890f02f6 patch 8.2.2176: crash with a sequence of fold commands
Bram Moolenaar <Bram@vim.org>
parents: 23027
diff changeset
1075 bwipe!
ef4f890f02f6 patch 8.2.2176: crash with a sequence of fold commands
Bram Moolenaar <Bram@vim.org>
parents: 23027
diff changeset
1076 endfunc
ef4f890f02f6 patch 8.2.2176: crash with a sequence of fold commands
Bram Moolenaar <Bram@vim.org>
parents: 23027
diff changeset
1077
23687
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1078 func Test_fold_relative_move()
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1079 new
23687
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1080 set fdm=indent sw=2 wrap tw=80
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1081
24341
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1082 let longtext = repeat('x', &columns + 1)
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1083 let content = [ ' foo', ' ' .. longtext, ' baz',
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1084 \ longtext,
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1085 \ ' foo', ' ' .. longtext, ' baz'
23687
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1086 \ ]
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1087 call append(0, content)
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1088
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1089 normal zM
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1090
24341
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1091 for lnum in range(1, 3)
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1092 call cursor(lnum, 1)
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1093 call assert_true(foldclosed(line('.')))
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1094 normal gj
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1095 call assert_equal(2, winline())
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1096 endfor
23687
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1097
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1098 call cursor(2, 1)
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1099 call assert_true(foldclosed(line('.')))
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1100 normal 2gj
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1101 call assert_equal(3, winline())
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1102
24341
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1103 for lnum in range(5, 7)
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1104 call cursor(lnum, 1)
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1105 call assert_true(foldclosed(line('.')))
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1106 normal gk
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1107 call assert_equal(3, winline())
0e1b8b98f9f4 patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents: 24287
diff changeset
1108 endfor
23687
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1109
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1110 call cursor(6, 1)
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1111 call assert_true(foldclosed(line('.')))
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1112 normal 2gk
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1113 call assert_equal(2, winline())
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1114
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1115 set fdm& sw& wrap& tw&
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1116 bw!
23687
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1117 endfunc
09ad3f1b9714 patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents: 23260
diff changeset
1118
24043
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1119 " Test for using multibyte characters as 'foldopen', 'foldclose' and
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1120 " 'foldsetp' items in 'fillchars'
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1121 func s:mbyte_fillchar_tests(fo, fc, fs)
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1122 setlocal foldcolumn=3
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1123
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1124 normal zE
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1125 1,2fold
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1126 call assert_equal([a:fc .. ' +-- 2 ', ' three '],
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1127 \ ScreenLines([1, 2], 10))
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1128 1,2foldopen
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1129 call assert_equal([a:fo .. ' one ', a:fs .. ' two '],
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1130 \ ScreenLines([1, 2], 7))
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1131 1,2foldclose
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1132 redraw!
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1133 call assert_equal([a:fc .. ' +-- 2 ', ' three '],
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1134 \ ScreenLines([1, 2], 10))
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1135
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1136 " Two level fold
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1137 normal zE
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1138 2,3fold
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1139 1,4fold
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1140 call assert_equal([a:fc .. ' +-- 4 ', ' five '],
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1141 \ ScreenLines([1, 2], 10))
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1142 1,4foldopen
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1143 call assert_equal([a:fo .. ' one ', a:fs .. a:fc .. ' +--- 2'],
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1144 \ ScreenLines([1, 2], 10))
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1145 1,4foldopen
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1146 call assert_equal([a:fo .. ' one ', a:fs .. a:fo .. ' two ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1147 \ a:fs .. a:fs .. ' three '], ScreenLines([1, 3], 10))
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1148 2,3foldclose
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1149 call assert_equal([a:fo .. ' one ', a:fs .. a:fc .. ' +--- 2'],
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1150 \ ScreenLines([1, 2], 10))
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1151 1,4foldclose
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1152 call assert_equal([a:fc .. ' +-- 4 ', ' five '],
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1153 \ ScreenLines([1, 2], 10))
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1154
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1155 " Three level fold
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1156 normal zE
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1157 3,4fold
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1158 2,5fold
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1159 1,6fold
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1160 call assert_equal([a:fc .. ' +-- 6 '], ScreenLines(1, 10))
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1161 " open all the folds
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1162 normal zR
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1163 call assert_equal([
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1164 \ a:fo .. ' one ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1165 \ a:fs .. a:fo .. ' two ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1166 \ '2' .. a:fo .. ' three ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1167 \ '23 four ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1168 \ a:fs .. a:fs .. ' five ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1169 \ a:fs .. ' six ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1170 \ ], ScreenLines([1, 6], 10))
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1171 " close the innermost fold
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1172 3,4foldclose
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1173 call assert_equal([
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1174 \ a:fo .. ' one ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1175 \ a:fs .. a:fo .. ' two ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1176 \ a:fs .. a:fs .. a:fc .. '+---- ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1177 \ a:fs .. a:fs .. ' five ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1178 \ a:fs .. ' six ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1179 \ ], ScreenLines([1, 5], 10))
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1180 " close the next fold
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1181 2,5foldclose
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1182 call assert_equal([
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1183 \ a:fo .. ' one ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1184 \ a:fs .. a:fc .. ' +--- 4',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1185 \ a:fs .. ' six ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1186 \ ], ScreenLines([1, 3], 10))
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1187
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1188 " set the fold column size to 2
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1189 setlocal fdc=2
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1190 normal zR
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1191 call assert_equal([
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1192 \ a:fo .. ' one ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1193 \ a:fo .. ' two ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1194 \ a:fo .. ' three',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1195 \ '3 four ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1196 \ '2 five ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1197 \ a:fs .. ' six ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1198 \ ], ScreenLines([1, 6], 7))
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1199
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1200 " set the fold column size to 1
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1201 setlocal fdc=1
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1202 normal zR
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1203 call assert_equal([
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1204 \ a:fo .. 'one ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1205 \ a:fo .. 'two ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1206 \ a:fo .. 'three ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1207 \ '3four ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1208 \ '2five ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1209 \ a:fs .. 'six ',
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1210 \ ], ScreenLines([1, 6], 7))
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1211
24055
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1212 " Enable number and sign columns and place some signs
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1213 setlocal fdc=3
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1214 setlocal number
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1215 setlocal signcolumn=auto
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1216 sign define S1 text=->
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1217 sign place 10 line=3 name=S1
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1218 call assert_equal([
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1219 \ a:fo .. ' 1 one ',
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1220 \ a:fs .. a:fo .. ' 2 two ',
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1221 \ '2' .. a:fo .. ' -> 3 three',
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1222 \ '23 4 four ',
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1223 \ a:fs .. a:fs .. ' 5 five ',
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1224 \ a:fs .. ' 6 six '
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1225 \ ], ScreenLines([1, 6], 14))
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1226
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1227 " Test with 'rightleft'
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1228 if has('rightleft')
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1229 setlocal rightleft
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1230 let lines = ScreenLines([1, 6], winwidth(0))
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1231 call assert_equal('o 1 ' .. a:fo,
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1232 \ strcharpart(lines[0], strchars(lines[0]) - 10, 10))
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1233 call assert_equal('t 2 ' .. a:fo .. a:fs,
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1234 \ strcharpart(lines[1], strchars(lines[1]) - 10, 10))
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1235 call assert_equal('t 3 >- ' .. a:fo .. '2',
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1236 \ strcharpart(lines[2], strchars(lines[2]) - 10, 10))
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1237 call assert_equal('f 4 32',
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1238 \ strcharpart(lines[3], strchars(lines[3]) - 10, 10))
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1239 call assert_equal('f 5 ' .. a:fs .. a:fs,
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1240 \ strcharpart(lines[4], strchars(lines[4]) - 10, 10))
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1241 call assert_equal('s 6 ' .. a:fs,
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1242 \ strcharpart(lines[5], strchars(lines[5]) - 10, 10))
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1243 setlocal norightleft
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1244 endif
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1245
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1246 sign unplace *
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1247 sign undefine S1
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1248 setlocal number& signcolumn&
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1249
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1250 " Add a test with more than 9 folds (and then delete some folds)
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1251 normal zE
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1252 for i in range(1, 10)
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1253 normal zfGzo
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1254 endfor
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1255 normal zR
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1256 call assert_equal([
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1257 \ a:fo .. a:fo .. ' one ',
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1258 \ '9> two '
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1259 \ ], ScreenLines([1, 2], 7))
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1260 normal 1Gzd
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1261 call assert_equal([
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1262 \ a:fo .. a:fo .. ' one ',
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1263 \ '89 two '
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1264 \ ], ScreenLines([1, 2], 7))
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1265 normal 1Gzdzdzdzdzdzdzd
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1266 call assert_equal([
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1267 \ a:fo .. a:fo .. ' one ',
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1268 \ a:fs .. a:fs .. ' two '
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1269 \ ], ScreenLines([1, 2], 7))
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1270
90d1636a8fcb patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Bram Moolenaar <Bram@vim.org>
parents: 24043
diff changeset
1271 setlocal foldcolumn& number& signcolumn&
24043
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1272 endfunc
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1273
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1274 func Test_foldcolumn_multibyte_char()
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1275 new
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1276 call setline(1, ['one', 'two', 'three', 'four', 'five', 'six'])
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1277 setlocal foldenable foldmethod=manual
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1278
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1279 " First test with the default setting
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1280 call s:mbyte_fillchar_tests('-', '+', '|')
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1281
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1282 " Use multi-byte characters
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1283 set fillchars+=foldopen:▾,foldsep:│,foldclose:▸
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1284 call s:mbyte_fillchar_tests('▾', '▸', '│')
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1285
24184
8ebf8b3dfc08 patch 8.2.2633: multi-byte 'fillchars' for folding do not show properly
Bram Moolenaar <Bram@vim.org>
parents: 24055
diff changeset
1286 " Use a mix of multi-byte and single-byte characters
8ebf8b3dfc08 patch 8.2.2633: multi-byte 'fillchars' for folding do not show properly
Bram Moolenaar <Bram@vim.org>
parents: 24055
diff changeset
1287 set fillchars+=foldopen:¬,foldsep:\|,foldclose:+
8ebf8b3dfc08 patch 8.2.2633: multi-byte 'fillchars' for folding do not show properly
Bram Moolenaar <Bram@vim.org>
parents: 24055
diff changeset
1288 call s:mbyte_fillchar_tests('¬', '+', '|')
8ebf8b3dfc08 patch 8.2.2633: multi-byte 'fillchars' for folding do not show properly
Bram Moolenaar <Bram@vim.org>
parents: 24055
diff changeset
1289 set fillchars+=foldopen:+,foldsep:\|,foldclose:¬
8ebf8b3dfc08 patch 8.2.2633: multi-byte 'fillchars' for folding do not show properly
Bram Moolenaar <Bram@vim.org>
parents: 24055
diff changeset
1290 call s:mbyte_fillchar_tests('+', '¬', '|')
8ebf8b3dfc08 patch 8.2.2633: multi-byte 'fillchars' for folding do not show properly
Bram Moolenaar <Bram@vim.org>
parents: 24055
diff changeset
1291
24043
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1292 bw!
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1293 set foldenable& fdc& fdm& fillchars&
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1294 endfunc
15408ab5fed7 patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'
Bram Moolenaar <Bram@vim.org>
parents: 23715
diff changeset
1295
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1296 " Test for calling foldlevel() from a fold expression
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1297 let g:FoldLevels = []
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1298 func FoldExpr1(lnum)
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1299 let f = [a:lnum]
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1300 for i in range(1, line('$'))
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1301 call add(f, foldlevel(i))
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1302 endfor
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1303 call add(g:FoldLevels, f)
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1304 return getline(a:lnum)[0] == "\t"
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1305 endfunc
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1306
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1307 func Test_foldexpr_foldlevel()
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1308 new
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1309 call setline(1, ['one', "\ttwo", "\tthree"])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1310 setlocal foldmethod=expr
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1311 setlocal foldexpr=FoldExpr1(v:lnum)
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1312 setlocal foldenable
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1313 setlocal foldcolumn=3
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1314 redraw!
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1315 call assert_equal([[1, -1, -1, -1], [2, -1, -1, -1], [3, 0, 1, -1]],
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1316 \ g:FoldLevels)
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1317 set foldmethod& foldexpr& foldenable& foldcolumn&
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1318 bw!
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1319 endfunc
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1320
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1321 " Test for returning different values from a fold expression
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1322 func FoldExpr2(lnum)
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1323 if a:lnum == 1 || a:lnum == 4
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1324 return -2
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1325 elseif a:lnum == 2
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1326 return 'a1'
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1327 elseif a:lnum == 3
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1328 return 's4'
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1329 endif
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1330 return '='
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1331 endfunc
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1332
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1333 func Test_foldexpr_2()
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1334 new
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1335 call setline(1, ['one', 'two', 'three', 'four'])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1336 setlocal foldexpr=FoldExpr2(v:lnum)
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1337 setlocal foldmethod=expr
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1338 call assert_equal([0, 1, 1, 0], [foldlevel(1), foldlevel(2), foldlevel(3),
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1339 \ foldlevel(4)])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1340 bw!
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1341 endfunc
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1342
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1343 " Test for the 'foldclose' option
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1344 func Test_foldclose_opt()
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1345 CheckScreendump
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1346
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1347 let lines =<< trim END
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1348 set foldmethod=manual foldclose=all foldopen=all
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1349 call setline(1, ['one', 'two', 'three', 'four'])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1350 2,3fold
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1351 func XsaveFoldLevels()
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1352 redraw!
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1353 call writefile([json_encode([foldclosed(1), foldclosed(2), foldclosed(3),
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1354 \ foldclosed(4)])], 'Xoutput', 'a')
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1355 endfunc
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1356 END
30552
a7a9e8b9af89 patch 9.0.0611: tests delete files with a separate delete() call
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
1357 call writefile(lines, 'Xscript', 'D')
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1358 let rows = 10
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1359 let buf = RunVimInTerminal('-S Xscript', {'rows': rows})
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1360 call term_wait(buf)
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1361 call term_sendkeys(buf, ":set noruler\n")
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1362 call term_wait(buf)
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1363 call term_sendkeys(buf, ":call XsaveFoldLevels()\n")
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1364 call term_sendkeys(buf, "2G")
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1365 call WaitForAssert({-> assert_equal('two', term_getline(buf, 2))})
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1366 call term_sendkeys(buf, ":call XsaveFoldLevels()\n")
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1367 call term_sendkeys(buf, "4G")
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1368 call WaitForAssert({-> assert_equal('four', term_getline(buf, 3))})
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1369 call term_sendkeys(buf, ":call XsaveFoldLevels()\n")
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1370 call term_sendkeys(buf, "3G")
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1371 call WaitForAssert({-> assert_equal('three', term_getline(buf, 3))})
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1372 call term_sendkeys(buf, ":call XsaveFoldLevels()\n")
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1373 call term_sendkeys(buf, "1G")
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1374 call WaitForAssert({-> assert_equal('four', term_getline(buf, 3))})
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1375 call term_sendkeys(buf, ":call XsaveFoldLevels()\n")
24345
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1376 call term_sendkeys(buf, "2G")
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1377 call WaitForAssert({-> assert_equal('two', term_getline(buf, 2))})
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1378 call term_sendkeys(buf, "k")
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1379 call WaitForAssert({-> assert_equal('four', term_getline(buf, 3))})
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1380
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1381 " clean up
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1382 call StopVimInTerminal(buf)
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1383
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1384 call assert_equal(['[-1,2,2,-1]', '[-1,-1,-1,-1]', '[-1,2,2,-1]',
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1385 \ '[-1,-1,-1,-1]', '[-1,2,2,-1]'], readfile('Xoutput'))
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1386 call delete('Xoutput')
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1387 endfunc
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1388
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1389 " Test for foldtextresult()
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1390 func Test_foldtextresult()
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1391 new
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1392 call assert_equal('', foldtextresult(-1))
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1393 call assert_equal('', foldtextresult(0))
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1394 call assert_equal('', foldtextresult(1))
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1395 call setline(1, ['one', 'two', 'three', 'four'])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1396 2,3fold
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1397 call assert_equal('', foldtextresult(1))
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1398 call assert_equal('+-- 2 lines: two', foldtextresult(2))
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1399 setlocal foldtext=
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1400 call assert_equal('+-- 2 lines folded ', foldtextresult(2))
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1401
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1402 " Fold text for a C comment fold
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1403 %d _
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1404 setlocal foldtext&
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1405 call setline(1, ['', '/*', ' * Comment', ' */', ''])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1406 2,4fold
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1407 call assert_equal('+-- 3 lines: Comment', foldtextresult(2))
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1408
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1409 bw!
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1410 endfunc
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1411
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1412 " Test for merging two recursive folds when an intermediate line with no fold
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1413 " is removed
30986
360f286b5869 patch 9.0.0828: various typos
Bram Moolenaar <Bram@vim.org>
parents: 30594
diff changeset
1414 func Test_fold_merge_recursive()
24287
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1415 new
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1416 call setline(1, [' one', ' two', 'xxxx', ' three',
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1417 \ ' four', "\tfive"])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1418 setlocal foldmethod=indent shiftwidth=2
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1419 3d_
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1420 %foldclose
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1421 call assert_equal([1, 5], [foldclosed(5), foldclosedend(1)])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1422 bw!
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1423 endfunc
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1424
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1425 " Test for moving a line which is the start of a fold from a recursive fold to
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1426 " outside. The fold length should reduce.
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1427 func Test_fold_move_foldlevel()
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1428 new
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1429 call setline(1, ['a{{{', 'b{{{', 'c{{{', 'd}}}', 'e}}}', 'f}}}', 'g'])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1430 setlocal foldmethod=marker
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1431 normal zR
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1432 call assert_equal([3, 2, 1], [foldlevel(4), foldlevel(5), foldlevel(6)])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1433 3move 7
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1434 call assert_equal([2, 1, 0], [foldlevel(3), foldlevel(4), foldlevel(5)])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1435 call assert_equal(1, foldlevel(7))
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1436
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1437 " Move a line from outside a fold to inside the fold.
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1438 %d _
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1439 call setline(1, ['a', 'b{{{', 'c}}}'])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1440 normal zR
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1441 1move 2
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1442 call assert_equal([1, 1, 1], [foldlevel(1), foldlevel(2), foldlevel(3)])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1443
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1444 " Move the start of one fold to inside another fold
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1445 %d _
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1446 call setline(1, ['a', 'b{{{', 'c}}}', 'd{{{', 'e}}}'])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1447 normal zR
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1448 call assert_equal([0, 1, 1, 1, 1], [foldlevel(1), foldlevel(2),
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1449 \ foldlevel(3), foldlevel(4), foldlevel(5)])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1450 1,2move 4
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1451 call assert_equal([0, 1, 1, 2, 2], [foldlevel(1), foldlevel(2),
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1452 \ foldlevel(3), foldlevel(4), foldlevel(5)])
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1453
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1454 bw!
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1455 endfunc
c2a234e8c896 patch 8.2.2684: not enough folding code is tested
Bram Moolenaar <Bram@vim.org>
parents: 24184
diff changeset
1456
24345
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1457 " Test for using zj and zk to move downwards and upwards to the start and end
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1458 " of the next fold.
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1459 " Test for using [z and ]z in a closed fold to jump to the beginning and end
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1460 " of the fold.
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1461 func Test_fold_jump()
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1462 new
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1463 call setline(1, ["\t1", "\t2", "\t\t3", "\t\t4", "\t\t\t5", "\t\t\t6", "\t\t7", "\t\t8", "\t9", "\t10"])
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1464 setlocal foldmethod=indent
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1465 normal zR
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1466 normal zj
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1467 call assert_equal(3, line('.'))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1468 normal zj
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1469 call assert_equal(5, line('.'))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1470 call assert_beeps('normal zj')
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1471 call assert_equal(5, line('.'))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1472 call assert_beeps('normal 9Gzj')
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1473 call assert_equal(9, line('.'))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1474 normal Gzk
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1475 call assert_equal(8, line('.'))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1476 normal zk
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1477 call assert_equal(6, line('.'))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1478 call assert_beeps('normal zk')
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1479 call assert_equal(6, line('.'))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1480 call assert_beeps('normal 2Gzk')
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1481 call assert_equal(2, line('.'))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1482
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1483 " Using [z or ]z in a closed fold should not move the cursor
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1484 %d _
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1485 call setline(1, ["1", "\t2", "\t3", "\t4", "\t5", "\t6", "7"])
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1486 normal zR4Gzc
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1487 call assert_equal(4, line('.'))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1488 call assert_beeps('normal [z')
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1489 call assert_equal(4, line('.'))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1490 call assert_beeps('normal ]z')
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1491 call assert_equal(4, line('.'))
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1492 bw!
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1493 endfunc
eab30779c97c patch 8.2.2713: folding code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 24341
diff changeset
1494
26743
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1495 " Test for using a script-local function for 'foldexpr'
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1496 func Test_foldexpr_scriptlocal_func()
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1497 func! s:FoldFunc()
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1498 let g:FoldLnum = v:lnum
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1499 endfunc
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1500 new | only
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1501 call setline(1, 'abc')
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1502 let g:FoldLnum = 0
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1503 set foldmethod=expr foldexpr=s:FoldFunc()
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1504 redraw!
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1505 call assert_equal(expand('<SID>') .. 'FoldFunc()', &foldexpr)
31821
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1506 call assert_equal(expand('<SID>') .. 'FoldFunc()', &g:foldexpr)
26743
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1507 call assert_equal(1, g:FoldLnum)
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1508 set foldmethod& foldexpr=
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1509 bw!
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1510 new | only
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1511 call setline(1, 'abc')
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1512 let g:FoldLnum = 0
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1513 set foldmethod=expr foldexpr=<SID>FoldFunc()
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1514 redraw!
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1515 call assert_equal(expand('<SID>') .. 'FoldFunc()', &foldexpr)
31821
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1516 call assert_equal(expand('<SID>') .. 'FoldFunc()', &g:foldexpr)
26743
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1517 call assert_equal(1, g:FoldLnum)
31821
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1518 bw!
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1519 call setline(1, 'abc')
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1520 setlocal foldmethod& foldexpr&
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1521 setglobal foldmethod=expr foldexpr=s:FoldFunc()
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1522 call assert_equal(expand('<SID>') .. 'FoldFunc()', &g:foldexpr)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1523 call assert_equal('0', &foldexpr)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1524 enew!
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1525 call setline(1, 'abc')
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1526 redraw!
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1527 call assert_equal(expand('<SID>') .. 'FoldFunc()', &foldexpr)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1528 call assert_equal(1, g:FoldLnum)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1529 bw!
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1530 call setline(1, 'abc')
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1531 setlocal foldmethod& foldexpr&
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1532 setglobal foldmethod=expr foldexpr=<SID>FoldFunc()
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1533 call assert_equal(expand('<SID>') .. 'FoldFunc()', &g:foldexpr)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1534 call assert_equal('0', &foldexpr)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1535 enew!
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1536 call setline(1, 'abc')
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1537 redraw!
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1538 call assert_equal(expand('<SID>') .. 'FoldFunc()', &foldexpr)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1539 call assert_equal(1, g:FoldLnum)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1540 set foldmethod& foldexpr&
26743
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1541 delfunc s:FoldFunc
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1542 bw!
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1543 endfunc
c2c40cefc17b patch 8.2.3900: it is not easy to use a script-local function for an option
Bram Moolenaar <Bram@vim.org>
parents: 24345
diff changeset
1544
26759
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1545 " Test for using a script-local function for 'foldtext'
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1546 func Test_foldtext_scriptlocal_func()
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1547 func! s:FoldText()
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1548 let g:FoldTextArgs = [v:foldstart, v:foldend]
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1549 return foldtext()
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1550 endfunc
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1551 new | only
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1552 call setline(1, range(50))
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1553 let g:FoldTextArgs = []
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1554 set foldtext=s:FoldText()
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1555 norm! 4Gzf4j
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1556 redraw!
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1557 call assert_equal(expand('<SID>') .. 'FoldText()', &foldtext)
31821
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1558 call assert_equal(expand('<SID>') .. 'FoldText()', &g:foldtext)
26759
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1559 call assert_equal([4, 8], g:FoldTextArgs)
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1560 set foldtext&
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1561 bw!
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1562 new | only
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1563 call setline(1, range(50))
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1564 let g:FoldTextArgs = []
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1565 set foldtext=<SID>FoldText()
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1566 norm! 8Gzf4j
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1567 redraw!
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1568 call assert_equal(expand('<SID>') .. 'FoldText()', &foldtext)
31821
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1569 call assert_equal(expand('<SID>') .. 'FoldText()', &g:foldtext)
26759
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1570 call assert_equal([8, 12], g:FoldTextArgs)
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1571 set foldtext&
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1572 bw!
31821
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1573 call setline(1, range(50))
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1574 let g:FoldTextArgs = []
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1575 setlocal foldtext&
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1576 setglobal foldtext=s:FoldText()
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1577 call assert_equal(expand('<SID>') .. 'FoldText()', &g:foldtext)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1578 call assert_equal('foldtext()', &foldtext)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1579 enew!
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1580 call setline(1, range(50))
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1581 norm! 12Gzf4j
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1582 redraw!
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1583 call assert_equal(expand('<SID>') .. 'FoldText()', &foldtext)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1584 call assert_equal([12, 16], g:FoldTextArgs)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1585 set foldtext&
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1586 bw!
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1587 call setline(1, range(50))
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1588 let g:FoldTextArgs = []
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1589 setlocal foldtext&
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1590 setglobal foldtext=<SID>FoldText()
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1591 call assert_equal(expand('<SID>') .. 'FoldText()', &g:foldtext)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1592 call assert_equal('foldtext()', &foldtext)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1593 enew!
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1594 call setline(1, range(50))
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1595 norm! 16Gzf4j
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1596 redraw!
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1597 call assert_equal(expand('<SID>') .. 'FoldText()', &foldtext)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1598 call assert_equal([16, 20], g:FoldTextArgs)
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1599 set foldtext&
5614e76f3dee patch 9.0.1243: :setglobal cannot use script-local function for "expr" option
Bram Moolenaar <Bram@vim.org>
parents: 31762
diff changeset
1600 bw!
26759
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1601 delfunc s:FoldText
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1602 endfunc
31c23760d590 patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents: 26743
diff changeset
1603
28578
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1604 " Make sure a fold containing a nested fold is split correctly when using
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1605 " foldmethod=indent
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1606 func Test_fold_split()
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1607 new
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1608 let lines =<< trim END
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1609 line 1
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1610 line 2
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1611 line 3
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1612 line 4
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1613 line 5
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1614 END
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1615 call setline(1, lines)
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1616 setlocal sw=2
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1617 setlocal foldmethod=indent foldenable
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1618 call assert_equal([0, 1, 1, 2, 2], range(1, 5)->map('foldlevel(v:val)'))
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1619 call append(2, 'line 2.5')
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1620 call assert_equal([0, 1, 0, 1, 2, 2], range(1, 6)->map('foldlevel(v:val)'))
29320
a74398c432a4 patch 9.0.0003: functions are global while they could be local
Bram Moolenaar <Bram@vim.org>
parents: 28974
diff changeset
1621 3d
a74398c432a4 patch 9.0.0003: functions are global while they could be local
Bram Moolenaar <Bram@vim.org>
parents: 28974
diff changeset
1622 call assert_equal([0, 1, 1, 2, 2], range(1, 5)->map('foldlevel(v:val)'))
28578
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1623 bw!
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1624 endfunc
8cba27db759a patch 8.2.4813: pasting text while indent folding may mess up folds
Bram Moolenaar <Bram@vim.org>
parents: 26759
diff changeset
1625
28823
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1626 " Make sure that when you append under a blank line that is under a fold with
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1627 " the same indent level as your appended line, the fold expands across the
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1628 " blank line
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1629 func Test_indent_append_under_blank_line()
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1630 new
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1631 let lines =<< trim END
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1632 line 1
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1633 line 2
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1634 line 3
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1635 END
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1636 call setline(1, lines)
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1637 setlocal sw=2
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1638 setlocal foldmethod=indent foldenable
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1639 call assert_equal([0, 1, 1], range(1, 3)->map('foldlevel(v:val)'))
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1640 call append(3, '')
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1641 call append(4, ' line 5')
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1642 call assert_equal([0, 1, 1, 1, 1], range(1, 5)->map('foldlevel(v:val)'))
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1643 bw!
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1644 endfunc
980eaa09f940 patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Bram Moolenaar <Bram@vim.org>
parents: 28578
diff changeset
1645
28929
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1646 " Make sure that when you delete 1 line of a fold whose length is 2 lines, the
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1647 " fold can't be closed since its length (1) is now less than foldminlines.
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1648 func Test_indent_one_line_fold_close()
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1649 let lines =<< trim END
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1650 line 1
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1651 line 2
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1652 line 3
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1653 END
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1654
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1655 new
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1656 setlocal sw=2 foldmethod=indent
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1657 call setline(1, lines)
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1658 " open all folds, delete line, then close all folds
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1659 normal zR
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1660 3delete
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1661 normal zM
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1662 call assert_equal(-1, foldclosed(2)) " the fold should not be closed
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1663
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1664 " Now do the same, but delete line 2 this time; this covers different code.
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1665 " (Combining this code with the above code doesn't expose both bugs.)
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1666 1,$delete
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1667 call setline(1, lines)
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1668 normal zR
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1669 2delete
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1670 normal zM
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1671 call assert_equal(-1, foldclosed(2))
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1672 bw!
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1673 endfunc
2ac9beab876c patch 8.2.4987: after deletion a small fold may be closable
Bram Moolenaar <Bram@vim.org>
parents: 28823
diff changeset
1674
28974
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1675 " Make sure that when appending [an indented line then a blank line] right
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1676 " before a single indented line, the resulting extended fold can be closed
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1677 func Test_indent_append_blank_small_fold_close()
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1678 new
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1679 setlocal sw=2 foldmethod=indent
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1680 " at first, the fold at the second line can't be closed since it's smaller
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1681 " than foldminlines
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1682 let lines =<< trim END
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1683 line 1
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1684 line 4
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1685 END
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1686 call setline(1, lines)
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1687 call append(1, [' line 2', ''])
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1688 " close all folds
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1689 normal zM
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1690 call assert_notequal(-1, foldclosed(2)) " the fold should be closed now
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1691 bw!
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1692 endfunc
65946c949965 patch 8.2.5009: fold may not be closeable after appending
Bram Moolenaar <Bram@vim.org>
parents: 28938
diff changeset
1693
31047
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1694 func Test_sort_closed_fold()
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1695 CheckExecutable sort
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1696
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1697 call setline(1, [
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1698 \ 'Section 1',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1699 \ ' how',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1700 \ ' now',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1701 \ ' brown',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1702 \ ' cow',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1703 \ 'Section 2',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1704 \ ' how',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1705 \ ' now',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1706 \ ' brown',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1707 \ ' cow',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1708 \])
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1709 setlocal foldmethod=indent sw=3
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1710 normal 2G
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1711
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1712 " The "!!" expands to ".,.+3" and must only sort four lines
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1713 call feedkeys("!!sort\<CR>", 'xt')
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1714 call assert_equal([
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1715 \ 'Section 1',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1716 \ ' brown',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1717 \ ' cow',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1718 \ ' how',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1719 \ ' now',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1720 \ 'Section 2',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1721 \ ' how',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1722 \ ' now',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1723 \ ' brown',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1724 \ ' cow',
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1725 \ ], getline(1, 10))
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1726
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1727 bwipe!
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1728 endfunc
ac1f548223a5 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
1729
31714
07480c2f5ea8 patch 9.0.1189: invalid memory access with folding and using "L"
Bram Moolenaar <Bram@vim.org>
parents: 31491
diff changeset
1730 func Test_indent_with_L_command()
07480c2f5ea8 patch 9.0.1189: invalid memory access with folding and using "L"
Bram Moolenaar <Bram@vim.org>
parents: 31491
diff changeset
1731 " The "L" command moved the cursor to line zero, causing the text saved for
07480c2f5ea8 patch 9.0.1189: invalid memory access with folding and using "L"
Bram Moolenaar <Bram@vim.org>
parents: 31491
diff changeset
1732 " undo to use line number -1, which caused trouble for undo later.
07480c2f5ea8 patch 9.0.1189: invalid memory access with folding and using "L"
Bram Moolenaar <Bram@vim.org>
parents: 31491
diff changeset
1733 new
07480c2f5ea8 patch 9.0.1189: invalid memory access with folding and using "L"
Bram Moolenaar <Bram@vim.org>
parents: 31491
diff changeset
1734 sil! norm 8R V{zf8=Lu
07480c2f5ea8 patch 9.0.1189: invalid memory access with folding and using "L"
Bram Moolenaar <Bram@vim.org>
parents: 31491
diff changeset
1735 bwipe!
07480c2f5ea8 patch 9.0.1189: invalid memory access with folding and using "L"
Bram Moolenaar <Bram@vim.org>
parents: 31491
diff changeset
1736 endfunc
07480c2f5ea8 patch 9.0.1189: invalid memory access with folding and using "L"
Bram Moolenaar <Bram@vim.org>
parents: 31491
diff changeset
1737
31762
b53ab3c3e0c9 patch 9.0.1213: adding a line below the last one does not expand fold
Bram Moolenaar <Bram@vim.org>
parents: 31714
diff changeset
1738 " Make sure that when there is a fold at the bottom of the buffer and a newline
b53ab3c3e0c9 patch 9.0.1213: adding a line below the last one does not expand fold
Bram Moolenaar <Bram@vim.org>
parents: 31714
diff changeset
1739 " character is appended to the line, the fold gets expanded (instead of the new
b53ab3c3e0c9 patch 9.0.1213: adding a line below the last one does not expand fold
Bram Moolenaar <Bram@vim.org>
parents: 31714
diff changeset
1740 " line not being part of the fold).
b53ab3c3e0c9 patch 9.0.1213: adding a line below the last one does not expand fold
Bram Moolenaar <Bram@vim.org>
parents: 31714
diff changeset
1741 func Test_expand_fold_at_bottom_of_buffer()
b53ab3c3e0c9 patch 9.0.1213: adding a line below the last one does not expand fold
Bram Moolenaar <Bram@vim.org>
parents: 31714
diff changeset
1742 new
b53ab3c3e0c9 patch 9.0.1213: adding a line below the last one does not expand fold
Bram Moolenaar <Bram@vim.org>
parents: 31714
diff changeset
1743 " create a fold on the only line
b53ab3c3e0c9 patch 9.0.1213: adding a line below the last one does not expand fold
Bram Moolenaar <Bram@vim.org>
parents: 31714
diff changeset
1744 fold
b53ab3c3e0c9 patch 9.0.1213: adding a line below the last one does not expand fold
Bram Moolenaar <Bram@vim.org>
parents: 31714
diff changeset
1745 execute "normal A\<CR>"
b53ab3c3e0c9 patch 9.0.1213: adding a line below the last one does not expand fold
Bram Moolenaar <Bram@vim.org>
parents: 31714
diff changeset
1746 call assert_equal([1, 1], range(1, 2)->map('foldlevel(v:val)'))
b53ab3c3e0c9 patch 9.0.1213: adding a line below the last one does not expand fold
Bram Moolenaar <Bram@vim.org>
parents: 31714
diff changeset
1747
b53ab3c3e0c9 patch 9.0.1213: adding a line below the last one does not expand fold
Bram Moolenaar <Bram@vim.org>
parents: 31714
diff changeset
1748 bwipe!
b53ab3c3e0c9 patch 9.0.1213: adding a line below the last one does not expand fold
Bram Moolenaar <Bram@vim.org>
parents: 31714
diff changeset
1749 endfunc
b53ab3c3e0c9 patch 9.0.1213: adding a line below the last one does not expand fold
Bram Moolenaar <Bram@vim.org>
parents: 31714
diff changeset
1750
31984
479c93ad4a3b patch 9.0.1324: "gj" and "gk" do not move correctly over a closed fold
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
1751 func Test_fold_screenrow_motion()
479c93ad4a3b patch 9.0.1324: "gj" and "gk" do not move correctly over a closed fold
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
1752 call setline(1, repeat(['aaaa'], 5))
479c93ad4a3b patch 9.0.1324: "gj" and "gk" do not move correctly over a closed fold
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
1753 1,4fold
479c93ad4a3b patch 9.0.1324: "gj" and "gk" do not move correctly over a closed fold
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
1754 norm Ggkzo
479c93ad4a3b patch 9.0.1324: "gj" and "gk" do not move correctly over a closed fold
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
1755 call assert_equal(1, line('.'))
479c93ad4a3b patch 9.0.1324: "gj" and "gk" do not move correctly over a closed fold
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
1756 endfunc
479c93ad4a3b patch 9.0.1324: "gj" and "gk" do not move correctly over a closed fold
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
1757
32549
cceee401aa51 patch 9.0.1606: using freed memory when 'foldcolumn' is set
Bram Moolenaar <Bram@vim.org>
parents: 31984
diff changeset
1758 " This was using freed memory
cceee401aa51 patch 9.0.1606: using freed memory when 'foldcolumn' is set
Bram Moolenaar <Bram@vim.org>
parents: 31984
diff changeset
1759 func Test_foldcolumn_linebreak_control_char()
cceee401aa51 patch 9.0.1606: using freed memory when 'foldcolumn' is set
Bram Moolenaar <Bram@vim.org>
parents: 31984
diff changeset
1760 CheckFeature linebreak
cceee401aa51 patch 9.0.1606: using freed memory when 'foldcolumn' is set
Bram Moolenaar <Bram@vim.org>
parents: 31984
diff changeset
1761
cceee401aa51 patch 9.0.1606: using freed memory when 'foldcolumn' is set
Bram Moolenaar <Bram@vim.org>
parents: 31984
diff changeset
1762 5vnew
cceee401aa51 patch 9.0.1606: using freed memory when 'foldcolumn' is set
Bram Moolenaar <Bram@vim.org>
parents: 31984
diff changeset
1763 setlocal foldcolumn=1 linebreak
cceee401aa51 patch 9.0.1606: using freed memory when 'foldcolumn' is set
Bram Moolenaar <Bram@vim.org>
parents: 31984
diff changeset
1764 call setline(1, "aaa\<C-A>b")
cceee401aa51 patch 9.0.1606: using freed memory when 'foldcolumn' is set
Bram Moolenaar <Bram@vim.org>
parents: 31984
diff changeset
1765 redraw
cceee401aa51 patch 9.0.1606: using freed memory when 'foldcolumn' is set
Bram Moolenaar <Bram@vim.org>
parents: 31984
diff changeset
1766 call assert_equal([' aaa^', ' Ab '], ScreenLines([1, 2], 5))
cceee401aa51 patch 9.0.1606: using freed memory when 'foldcolumn' is set
Bram Moolenaar <Bram@vim.org>
parents: 31984
diff changeset
1767 call assert_equal(screenattr(1, 5), screenattr(2, 2))
cceee401aa51 patch 9.0.1606: using freed memory when 'foldcolumn' is set
Bram Moolenaar <Bram@vim.org>
parents: 31984
diff changeset
1768
cceee401aa51 patch 9.0.1606: using freed memory when 'foldcolumn' is set
Bram Moolenaar <Bram@vim.org>
parents: 31984
diff changeset
1769 bwipe!
cceee401aa51 patch 9.0.1606: using freed memory when 'foldcolumn' is set
Bram Moolenaar <Bram@vim.org>
parents: 31984
diff changeset
1770 endfunc
cceee401aa51 patch 9.0.1606: using freed memory when 'foldcolumn' is set
Bram Moolenaar <Bram@vim.org>
parents: 31984
diff changeset
1771
33488
0081ca43bee9 patch 9.0.1995: Invalid memory access with empty 'foldexpr'
Christian Brabandt <cb@256bit.org>
parents: 32549
diff changeset
1772 " This used to cause invalid memory access
0081ca43bee9 patch 9.0.1995: Invalid memory access with empty 'foldexpr'
Christian Brabandt <cb@256bit.org>
parents: 32549
diff changeset
1773 func Test_foldexpr_return_empty_string()
0081ca43bee9 patch 9.0.1995: Invalid memory access with empty 'foldexpr'
Christian Brabandt <cb@256bit.org>
parents: 32549
diff changeset
1774 new
0081ca43bee9 patch 9.0.1995: Invalid memory access with empty 'foldexpr'
Christian Brabandt <cb@256bit.org>
parents: 32549
diff changeset
1775 setlocal foldexpr='' foldmethod=expr
0081ca43bee9 patch 9.0.1995: Invalid memory access with empty 'foldexpr'
Christian Brabandt <cb@256bit.org>
parents: 32549
diff changeset
1776 redraw
0081ca43bee9 patch 9.0.1995: Invalid memory access with empty 'foldexpr'
Christian Brabandt <cb@256bit.org>
parents: 32549
diff changeset
1777
0081ca43bee9 patch 9.0.1995: Invalid memory access with empty 'foldexpr'
Christian Brabandt <cb@256bit.org>
parents: 32549
diff changeset
1778 bwipe!
0081ca43bee9 patch 9.0.1995: Invalid memory access with empty 'foldexpr'
Christian Brabandt <cb@256bit.org>
parents: 32549
diff changeset
1779 endfunc
0081ca43bee9 patch 9.0.1995: Invalid memory access with empty 'foldexpr'
Christian Brabandt <cb@256bit.org>
parents: 32549
diff changeset
1780
34065
48955338edb1 patch 9.1.0002: a closing fold expr, may start a new fold
Christian Brabandt <cb@256bit.org>
parents: 33488
diff changeset
1781 " Make sure that when ending a fold that hasn't been started, it does not
48955338edb1 patch 9.1.0002: a closing fold expr, may start a new fold
Christian Brabandt <cb@256bit.org>
parents: 33488
diff changeset
1782 " start a new fold.
48955338edb1 patch 9.1.0002: a closing fold expr, may start a new fold
Christian Brabandt <cb@256bit.org>
parents: 33488
diff changeset
1783 func Test_foldexpr_end_fold()
48955338edb1 patch 9.1.0002: a closing fold expr, may start a new fold
Christian Brabandt <cb@256bit.org>
parents: 33488
diff changeset
1784 new
48955338edb1 patch 9.1.0002: a closing fold expr, may start a new fold
Christian Brabandt <cb@256bit.org>
parents: 33488
diff changeset
1785 setlocal foldmethod=expr
48955338edb1 patch 9.1.0002: a closing fold expr, may start a new fold
Christian Brabandt <cb@256bit.org>
parents: 33488
diff changeset
1786 let &l:foldexpr = 'v:lnum == 2 ? "<2" : "="'
48955338edb1 patch 9.1.0002: a closing fold expr, may start a new fold
Christian Brabandt <cb@256bit.org>
parents: 33488
diff changeset
1787 call setline(1, range(1, 3))
48955338edb1 patch 9.1.0002: a closing fold expr, may start a new fold
Christian Brabandt <cb@256bit.org>
parents: 33488
diff changeset
1788 redraw
48955338edb1 patch 9.1.0002: a closing fold expr, may start a new fold
Christian Brabandt <cb@256bit.org>
parents: 33488
diff changeset
1789 call assert_equal([0, 0, 0], range(1, 3)->map('foldlevel(v:val)'))
48955338edb1 patch 9.1.0002: a closing fold expr, may start a new fold
Christian Brabandt <cb@256bit.org>
parents: 33488
diff changeset
1790
48955338edb1 patch 9.1.0002: a closing fold expr, may start a new fold
Christian Brabandt <cb@256bit.org>
parents: 33488
diff changeset
1791 bwipe!
48955338edb1 patch 9.1.0002: a closing fold expr, may start a new fold
Christian Brabandt <cb@256bit.org>
parents: 33488
diff changeset
1792 endfunc
48955338edb1 patch 9.1.0002: a closing fold expr, may start a new fold
Christian Brabandt <cb@256bit.org>
parents: 33488
diff changeset
1793
20156
49694eceaa55 patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents: 18882
diff changeset
1794 " vim: shiftwidth=2 sts=2 expandtab