Mercurial > vim
comparison src/testdir/test_cindent.vim @ 17172:6990c1160ea5 v8.1.1585
patch 8.1.1585: :let-heredoc does not trim enough
commit https://github.com/vim/vim/commit/e7eb92708ec2092a2fc11e78703b5dcf83844412
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 24 00:58:07 2019 +0200
patch 8.1.1585: :let-heredoc does not trim enough
Problem: :let-heredoc does not trim enough.
Solution: Trim indent from the contents based on the indent of the first
line. Use let-heredoc in more tests.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 24 Jun 2019 01:00:05 +0200 |
parents | d615cc95089c |
children | f71ee7b04f0b |
comparison
equal
deleted
inserted
replaced
17171:1b0f624dcd8d | 17172:6990c1160ea5 |
---|---|
16 | 16 |
17 func Test_cino_extern_c() | 17 func Test_cino_extern_c() |
18 " Test for cino-E | 18 " Test for cino-E |
19 | 19 |
20 let without_ind =<< trim [CODE] | 20 let without_ind =<< trim [CODE] |
21 #ifdef __cplusplus | 21 #ifdef __cplusplus |
22 extern "C" { | 22 extern "C" { |
23 #endif | 23 #endif |
24 int func_a(void); | 24 int func_a(void); |
25 #ifdef __cplusplus | 25 #ifdef __cplusplus |
26 } | 26 } |
27 #endif | 27 #endif |
28 [CODE] | 28 [CODE] |
29 | 29 |
30 let with_ind =<< trim [CODE] | 30 let with_ind =<< trim [CODE] |
31 #ifdef __cplusplus | 31 #ifdef __cplusplus |
32 extern "C" { | 32 extern "C" { |
33 #endif | 33 #endif |
34 int func_a(void); | 34 int func_a(void); |
35 #ifdef __cplusplus | 35 #ifdef __cplusplus |
36 } | 36 } |
37 #endif | 37 #endif |
38 [CODE] | 38 [CODE] |
39 new | 39 new |
40 setlocal cindent cinoptions=E0 | 40 setlocal cindent cinoptions=E0 |
41 call setline(1, without_ind) | 41 call setline(1, without_ind) |
42 call feedkeys("gg=G", 'tx') | 42 call feedkeys("gg=G", 'tx') |
87 func! MyIndentFunction() | 87 func! MyIndentFunction() |
88 return v:lnum == 1 ? shiftwidth() : 0 | 88 return v:lnum == 1 ? shiftwidth() : 0 |
89 endfunc | 89 endfunc |
90 setl expandtab sw=8 indentkeys+=; indentexpr=MyIndentFunction() | 90 setl expandtab sw=8 indentkeys+=; indentexpr=MyIndentFunction() |
91 let testinput =<< trim [CODE] | 91 let testinput =<< trim [CODE] |
92 var_a = something() | 92 var_a = something() |
93 b = something() | 93 b = something() |
94 [CODE] | 94 [CODE] |
95 call setline(1, testinput) | 95 call setline(1, testinput) |
96 call cursor(1, 1) | 96 call cursor(1, 1) |
97 call feedkeys("^\<c-v>j$A;\<esc>", 'tnix') | 97 call feedkeys("^\<c-v>j$A;\<esc>", 'tnix') |
98 let expected =<< trim [CODE] | 98 let expected =<< [CODE] |
99 var_a = something(); | 99 var_a = something(); |
100 b = something(); | 100 b = something(); |
101 [CODE] | 101 [CODE] |
102 call assert_equal(expected, getline(1, '$')) | 102 call assert_equal(expected, getline(1, '$')) |
103 | 103 |
104 %d | 104 %d |
105 let testinput =<< trim [CODE] | 105 let testinput =<< [CODE] |
106 var_a = something() | 106 var_a = something() |
107 b = something() | 107 b = something() |
108 [CODE] | 108 [CODE] |
109 call setline(1, testinput) | 109 call setline(1, testinput) |
110 call cursor(1, 1) | 110 call cursor(1, 1) |
111 call feedkeys("^\<c-v>j$A;\<esc>", 'tnix') | 111 call feedkeys("^\<c-v>j$A;\<esc>", 'tnix') |
112 let expected =<< trim [CODE] | 112 let expected =<< [CODE] |
113 var_a = something(); | 113 var_a = something(); |
114 b = something() | 114 b = something() |
115 [CODE] | 115 [CODE] |
116 call assert_equal(expected, getline(1, '$')) | 116 call assert_equal(expected, getline(1, '$')) |
117 bw! | 117 bw! |
118 endfunc | 118 endfunc |
119 | 119 |
120 func Test_cindent_func() | 120 func Test_cindent_func() |
2067 setl cindent ts=4 sw=4 | 2067 setl cindent ts=4 sw=4 |
2068 setl tw=0 noai fo=croq | 2068 setl tw=0 noai fo=croq |
2069 let &wm = &columns - 20 | 2069 let &wm = &columns - 20 |
2070 | 2070 |
2071 let code =<< trim [CODE] | 2071 let code =<< trim [CODE] |
2072 { | 2072 { |
2073 | 2073 |
2074 /* this is | 2074 /* this is |
2075 * a real serious important big | 2075 * a real serious important big |
2076 * comment | 2076 * comment |
2077 */ | 2077 */ |
2078 /* insert " about life, the universe, and the rest" after "serious" */ | 2078 /* insert " about life, the universe, and the rest" after "serious" */ |
2079 } | 2079 } |
2080 [CODE] | 2080 [CODE] |
2081 | 2081 |
2082 call append(0, code) | 2082 call append(0, code) |
2083 normal gg | 2083 normal gg |
2084 call search('serious', 'e') | 2084 call search('serious', 'e') |
3241 func Test_cindent_30() | 3241 func Test_cindent_30() |
3242 new | 3242 new |
3243 setl cindent ts=4 sw=4 | 3243 setl cindent ts=4 sw=4 |
3244 setl cino=+20 | 3244 setl cino=+20 |
3245 | 3245 |
3246 let code =<< trim [CODE] | 3246 let code =<< [CODE] |
3247 void | 3247 void |
3248 foo() | 3248 foo() |
3249 { | 3249 { |
3250 if (a) | 3250 if (a) |
3251 { | 3251 { |
3252 } else | 3252 } else |
3253 asdf; | 3253 asdf; |
3254 } | 3254 } |
3255 [CODE] | 3255 [CODE] |
3256 | 3256 |
3257 call append(0, code) | 3257 call append(0, code) |
3258 normal gg | 3258 normal gg |
3259 normal ]]=][ | 3259 normal ]]=][ |
3260 | 3260 |
3261 let expected =<< trim [CODE] | 3261 let expected =<< [CODE] |
3262 void | 3262 void |
3263 foo() | 3263 foo() |
3264 { | 3264 { |
3265 if (a) | 3265 if (a) |
3266 { | 3266 { |
3267 } else | 3267 } else |
3268 asdf; | 3268 asdf; |
3269 } | 3269 } |
3270 | 3270 |
3271 [CODE] | 3271 [CODE] |
3272 | 3272 |
3273 call assert_equal(expected, getline(1, '$')) | 3273 call assert_equal(expected, getline(1, '$')) |
3274 enew! | close | 3274 enew! | close |
3275 endfunc | 3275 endfunc |
3276 | 3276 |
3459 call append(0, code) | 3459 call append(0, code) |
3460 normal gg | 3460 normal gg |
3461 normal =][ | 3461 normal =][ |
3462 | 3462 |
3463 let expected =<< trim [CODE] | 3463 let expected =<< trim [CODE] |
3464 | 3464 |
3465 void | 3465 void |
3466 func(int a | 3466 func(int a |
3467 #if defined(FOO) | 3467 #if defined(FOO) |
3468 , int b | 3468 , int b |
3469 , int c | 3469 , int c |