Mercurial > vim
comparison src/testdir/test_cindent.vim @ 11087:242e0617aa51 v8.0.0431
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
commit https://github.com/vim/vim/commit/7720ba8599162fbbb8f7fc034f674a2ccd3ca7f1
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Mar 8 22:19:26 2017 +0100
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Problem: 'cinoptions' cannot set indent for extern block.
Solution: Add the "E" flag in 'cinoptions'. (Hirohito Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 08 Mar 2017 22:30:05 +0100 |
parents | 814126a34c9d |
children | 0066a7e178bc |
comparison
equal
deleted
inserted
replaced
11086:f283d02368ac | 11087:242e0617aa51 |
---|---|
12 norm! o#include | 12 norm! o#include |
13 "call feedkeys("o#include\<esc>", 't') | 13 "call feedkeys("o#include\<esc>", 't') |
14 call assert_equal(["#include <iostream>", "#include"], getline(1,2)) | 14 call assert_equal(["#include <iostream>", "#include"], getline(1,2)) |
15 bwipe! | 15 bwipe! |
16 endfunc | 16 endfunc |
17 | |
18 func Test_cino_extern_c() | |
19 " Test for cino-E | |
20 | |
21 let without_ind = [ | |
22 \ '#ifdef __cplusplus', | |
23 \ 'extern "C" {', | |
24 \ '#endif', | |
25 \ 'int func_a(void);', | |
26 \ '#ifdef __cplusplus', | |
27 \ '}', | |
28 \ '#endif' | |
29 \ ] | |
30 | |
31 let with_ind = [ | |
32 \ '#ifdef __cplusplus', | |
33 \ 'extern "C" {', | |
34 \ '#endif', | |
35 \ "\tint func_a(void);", | |
36 \ '#ifdef __cplusplus', | |
37 \ '}', | |
38 \ '#endif' | |
39 \ ] | |
40 new | |
41 setlocal cindent cinoptions=E0 | |
42 call setline(1, without_ind) | |
43 call feedkeys("gg=G", 'tx') | |
44 call assert_equal(with_ind, getline(1, '$')) | |
45 | |
46 setlocal cinoptions=E-s | |
47 call setline(1, with_ind) | |
48 call feedkeys("gg=G", 'tx') | |
49 call assert_equal(without_ind, getline(1, '$')) | |
50 | |
51 setlocal cinoptions=Es | |
52 let tests = [ | |
53 \ ['recognized', ['extern "C" {'], "\t\t;"], | |
54 \ ['recognized', ['extern "C++" {'], "\t\t;"], | |
55 \ ['recognized', ['extern /* com */ "C"{'], "\t\t;"], | |
56 \ ['recognized', ['extern"C"{'], "\t\t;"], | |
57 \ ['recognized', ['extern "C"', '{'], "\t\t;"], | |
58 \ ['not recognized', ['extern {'], "\t;"], | |
59 \ ['not recognized', ['extern /*"C"*/{'], "\t;"], | |
60 \ ['not recognized', ['extern "C" //{'], ";"], | |
61 \ ['not recognized', ['extern "C" /*{*/'], ";"], | |
62 \ ] | |
63 | |
64 for pair in tests | |
65 let lines = pair[1] | |
66 call setline(1, lines) | |
67 call feedkeys(len(lines) . "Go;", 'tx') | |
68 call assert_equal(pair[2], getline(len(lines) + 1), 'Failed for "' . string(lines) . '"') | |
69 endfor | |
70 | |
71 | |
72 | |
73 bwipe! | |
74 endfunc | |
75 | |
76 " vim: shiftwidth=2 sts=2 expandtab |