|
| 1 | +" Test for folding |
| 2 | + |
| 3 | +function! Test_address_fold() |
| 4 | + new |
| 5 | + call setline(1, ['int FuncName() {/*{{{*/', 1, 2, 3, 4, 5, '}/*}}}*/', |
| 6 | + \ 'after fold 1', 'after fold 2', 'after fold 3']) |
| 7 | + setl fen fdm=marker |
| 8 | + " The next ccommands should all copy the same part of the buffer, |
| 9 | + " regardless of the adressing type, since the part to be copied |
| 10 | + " is folded away |
| 11 | + :1y |
| 12 | + call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1)) |
| 13 | + :.y |
| 14 | + call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1)) |
| 15 | + :.+y |
| 16 | + call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1)) |
| 17 | + :.,.y |
| 18 | + call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1)) |
| 19 | + :sil .1,.y |
| 20 | + call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1)) |
| 21 | + " use silent to make E493 go away |
| 22 | + :sil .+,.y |
| 23 | + call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1)) |
| 24 | + :,y |
| 25 | + call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1)) |
| 26 | + :,+y |
| 27 | + call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/','after fold 1'], getreg(0,1,1)) |
| 28 | + " using .+3 as second address should copy the whole folded line + the next 3 |
| 29 | + " lines |
| 30 | + :.,+3y |
| 31 | + call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/', |
| 32 | + \ 'after fold 1', 'after fold 2', 'after fold 3'], getreg(0,1,1)) |
| 33 | + :sil .,-2y |
| 34 | + call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1)) |
| 35 | + |
| 36 | + " now test again with folding disabled |
| 37 | + set nofoldenable |
| 38 | + :1y |
| 39 | + call assert_equal(['int FuncName() {/*{{{*/'], getreg(0,1,1)) |
| 40 | + :.y |
| 41 | + call assert_equal(['int FuncName() {/*{{{*/'], getreg(0,1,1)) |
| 42 | + :.+y |
| 43 | + call assert_equal(['1'], getreg(0,1,1)) |
| 44 | + :.,.y |
| 45 | + call assert_equal(['int FuncName() {/*{{{*/'], getreg(0,1,1)) |
| 46 | + " use silent to make E493 go away |
| 47 | + :sil .1,.y |
| 48 | + call assert_equal(['int FuncName() {/*{{{*/', '1'], getreg(0,1,1)) |
| 49 | + " use silent to make E493 go away |
| 50 | + :sil .+,.y |
| 51 | + call assert_equal(['int FuncName() {/*{{{*/', '1'], getreg(0,1,1)) |
| 52 | + :,y |
| 53 | + call assert_equal(['int FuncName() {/*{{{*/'], getreg(0,1,1)) |
| 54 | + :,+y |
| 55 | + call assert_equal(['int FuncName() {/*{{{*/', '1'], getreg(0,1,1)) |
| 56 | + " using .+3 as second address should copy the whole folded line + the next 3 |
| 57 | + " lines |
| 58 | + :.,+3y |
| 59 | + call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3'], getreg(0,1,1)) |
| 60 | + :7 |
| 61 | + :sil .,-2y |
| 62 | + call assert_equal(['4', '5', '}/*}}}*/'], getreg(0,1,1)) |
| 63 | + |
| 64 | + quit! |
| 65 | +endfunction |
| 66 | + |
| 67 | +function! Test_indent_fold() |
| 68 | + new |
| 69 | + call setline(1, ['', 'a', ' b', ' c']) |
| 70 | + setl fen fdm=indent |
| 71 | + 2 |
| 72 | + norm! >> |
| 73 | + let a=map(range(1,4), 'foldclosed(v:val)') |
| 74 | + call assert_equal([-1,-1,-1,-1], a) |
| 75 | +endfu |
| 76 | + |
| 77 | +function! Test_indent_fold() |
| 78 | + new |
| 79 | + call setline(1, ['', 'a', ' b', ' c']) |
| 80 | + setl fen fdm=indent |
| 81 | + 2 |
| 82 | + norm! >> |
| 83 | + let a=map(range(1,4), 'foldclosed(v:val)') |
| 84 | + call assert_equal([-1,-1,-1,-1], a) |
| 85 | + bw! |
| 86 | +endfu |
| 87 | + |
| 88 | +function! Test_indent_fold2() |
| 89 | + new |
| 90 | + call setline(1, ['', '{{{', '}}}', '{{{', '}}}']) |
| 91 | + setl fen fdm=marker |
| 92 | + 2 |
| 93 | + norm! >> |
| 94 | + let a=map(range(1,5), 'foldclosed(v:val)') |
| 95 | + call assert_equal([-1,-1,-1,4,4], a) |
| 96 | + bw! |
| 97 | +endfu |
0 commit comments