Mercurial > vim
annotate src/testdir/test_smartindent.vim @ 27609:766a329fe5bb v8.2.4331
patch 8.2.4331: Vim9: no test for existing script variable in block
Commit: https://github.com/vim/vim/commit/3a5988c025f8517ba382730dc54bb13df937edb4
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 8 19:23:35 2022 +0000
patch 8.2.4331: Vim9: no test for existing script variable in block
Problem: Vim9: no test for existing script variable in block.
Solution: Add a test.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 08 Feb 2022 20:30:02 +0100 |
parents | dc3d45d9a4a8 |
children | 948877671c54 |
rev | line source |
---|---|
11943
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
1 " Tests for smartindent |
10145
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 " Tests for not doing smart indenting when it isn't set. |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
11943
diff
changeset
|
4 func Test_nosmartindent() |
10145
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 new |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 call append(0, [" some test text", |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
11943
diff
changeset
|
7 \ " test text", |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
11943
diff
changeset
|
8 \ "test text", |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
11943
diff
changeset
|
9 \ " test text"]) |
10145
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 set nocindent nosmartindent autoindent |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 exe "normal! gg/some\<CR>" |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 exe "normal! 2cc#test\<Esc>" |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 call assert_equal(" #test", getline(1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 enew! | close |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
11943
diff
changeset
|
15 endfunc |
11943
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
16 |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
11943
diff
changeset
|
17 func MyIndent() |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
11943
diff
changeset
|
18 endfunc |
11943
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
19 |
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
20 " When 'indentexpr' is set, setting 'si' has no effect. |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
11943
diff
changeset
|
21 func Test_smartindent_has_no_effect() |
11943
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
22 new |
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
23 exe "normal! i\<Tab>one\<Esc>" |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
24 setlocal noautoindent smartindent indentexpr= |
11943
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
25 exe "normal! Gotwo\<Esc>" |
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
26 call assert_equal("\ttwo", getline("$")) |
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
27 |
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
28 set indentexpr=MyIndent |
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
29 exe "normal! Gothree\<Esc>" |
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
30 call assert_equal("three", getline("$")) |
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
31 |
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
32 delfunction! MyIndent |
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
33 bwipe! |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
11943
diff
changeset
|
34 endfunc |
11943
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
35 |
19603
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
36 " Test for inserting '{' and '} with smartindent |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
37 func Test_smartindent_braces() |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
38 new |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
39 setlocal smartindent shiftwidth=4 |
19603
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
40 call setline(1, [' if (a)', "\tif (b)", "\t return 1"]) |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
41 normal 2ggO{ |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
42 normal 3ggA { |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
43 normal 4ggo} |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
44 normal o} |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
45 normal 4ggO#define FOO 1 |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
46 call assert_equal([ |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
47 \ ' if (a)', |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
48 \ ' {', |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
49 \ "\tif (b) {", |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
50 \ '#define FOO 1', |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
51 \ "\t return 1", |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
52 \ "\t}", |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
53 \ ' }' |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
54 \ ], getline(1, '$')) |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
55 close! |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
56 endfunc |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
57 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
58 " Test for adding a new line before and after comments with smartindent |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
59 func Test_si_add_line_around_comment() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
60 new |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
61 setlocal smartindent shiftwidth=4 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
62 call setline(1, [' A', '# comment1', '# comment2']) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
63 exe "normal GoC\<Esc>2GOB" |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
64 call assert_equal([' A', ' B', '# comment1', '# comment2', ' C'], |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
65 \ getline(1, '$')) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
66 close! |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
67 endfunc |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
68 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
69 " After a C style comment, indent for a following line should line up with the |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
70 " line containing the start of the comment. |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
71 func Test_si_indent_after_c_comment() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
72 new |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
73 setlocal smartindent shiftwidth=4 fo+=ro |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
74 exe "normal i\<C-t>/*\ncomment\n/\n#define FOOBAR\n75\<Esc>ggOabc" |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
75 normal 3jOcont |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
76 call assert_equal([' abc', ' /*', ' * comment', ' * cont', |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
77 \ ' */', '#define FOOBAR', ' 75'], getline(1, '$')) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
78 close! |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
79 endfunc |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
80 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
81 " Test for indenting a statement after a if condition split across lines |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
82 func Test_si_if_cond_split_across_lines() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
83 new |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
84 setlocal smartindent shiftwidth=4 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
85 exe "normal i\<C-t>if (cond1 &&\n\<C-t>cond2) {\ni = 10;\n}" |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
86 call assert_equal([' if (cond1 &&', "\t cond2) {", "\ti = 10;", |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
87 \ ' }'], getline(1, '$')) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
88 close! |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
89 endfunc |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
90 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
91 " Test for inserting lines before and after a one line comment |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
92 func Test_si_one_line_comment() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
93 new |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
94 setlocal smartindent shiftwidth=4 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
95 exe "normal i\<C-t>abc;\n\<C-t>/* comment */" |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
96 normal oi = 10; |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
97 normal kOj = 1; |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
98 call assert_equal([' abc;', "\tj = 1;", "\t/* comment */", "\ti = 10;"], |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
99 \ getline(1, '$')) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
100 close! |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
101 endfunc |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
102 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
103 " Test for smartindent with a comment continued across multiple lines |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
104 func Test_si_comment_line_continuation() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
105 new |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
106 setlocal smartindent shiftwidth=4 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
107 call setline(1, ['# com1', '# com2 \', ' contd', '# com3', ' xyz']) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
108 normal ggOabc |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
109 call assert_equal([' abc', '# com1', '# com2 \', ' contd', '# com3', |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19603
diff
changeset
|
110 \ ' xyz'], getline(1, '$')) |
19603
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
111 close! |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
112 endfunc |
6d3c683466f4
patch 8.2.0358: insufficient testing for indent.c
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
113 |
24946
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
114 " When 'paste' is set, 'smartindent' should not take effect. |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
115 func Test_si_with_paste() |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
116 new |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
117 setlocal smartindent autoindent |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
118 set paste |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
119 " insert text that will trigger smartindent |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
120 exe "norm! i {\nif (x)\ni = 1;\n#define FOO 1\nj = 2;\n}" |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
121 exe "norm! Ok = 3;" |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
122 exe "norm! 4G>>" |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
123 call assert_equal([' {', 'if (x)', 'i = 1;', '#define FOO 1', |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
124 \ 'j = 2;', 'k = 3;', '}'], getline(1, '$')) |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
125 call assert_true(&smartindent) |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
126 set nopaste |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
127 %d _ |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
128 exe "norm! i {\nif (x)\ni = 1;\n#define FOO 1\nj = 2;\n}" |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
129 exe "norm! Ok = 3;" |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
130 exe "norm! 4G>>" |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
131 call assert_equal([' {', "\t if (x)", "\t\t i = 1;", |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
132 \ '#define FOO 1', "\t\t j = 2;", "\t k = 3;", ' }'], |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
133 \ getline(1, '$')) |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
134 bw! |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
135 endfunc |
dc3d45d9a4a8
patch 8.2.3010: not enough testing for viminfo code
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
136 |
11943
268b1036cd17
patch 8.0.0851: 'smartindent' is used even when 'indentexpr' is set
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
137 " vim: shiftwidth=2 sts=2 expandtab |