1
0
forked from aniani/vim

updated for version 7.3.332

Problem:    Indent after "public:" is not increased in C++ code. (Lech Lorens)
Solution:   Check for namespace after the regular checks. (partly by Martin
            Gieseking)
This commit is contained in:
Bram Moolenaar 2011-10-04 18:03:47 +02:00
parent aa0e80471f
commit e79d1535cf
4 changed files with 78 additions and 44 deletions

View File

@ -6389,6 +6389,7 @@ get_c_indent()
int lookfor_cpp_namespace = FALSE; int lookfor_cpp_namespace = FALSE;
int cont_amount = 0; /* amount for continuation line */ int cont_amount = 0; /* amount for continuation line */
int original_line_islabel; int original_line_islabel;
int added_to_amount = 0;
for (options = curbuf->b_p_cino; *options; ) for (options = curbuf->b_p_cino; *options; )
{ {
@ -7216,8 +7217,25 @@ get_c_indent()
else else
amount += ind_continuation; amount += ind_continuation;
} }
else if (lookfor_cpp_namespace) else
{ {
if (lookfor != LOOKFOR_TERM
&& lookfor != LOOKFOR_CPP_BASECLASS)
{
amount = scope_amount;
if (theline[0] == '{')
{
amount += ind_open_extra;
added_to_amount = ind_open_extra;
}
}
if (lookfor_cpp_namespace)
{
/*
* Looking for C++ namespace, need to look further
* back.
*/
if (curwin->w_cursor.lnum == ourscope) if (curwin->w_cursor.lnum == ourscope)
continue; continue;
@ -7228,10 +7246,8 @@ get_c_indent()
l = ml_get_curline(); l = ml_get_curline();
/* /* If we're in a comment now, skip to the start of
* If we're in a comment now, skip to the start of the * the comment. */
* comment.
*/
trypos = find_start_comment(ind_maxcomment); trypos = find_start_comment(ind_maxcomment);
if (trypos != NULL) if (trypos != NULL)
{ {
@ -7240,28 +7256,20 @@ get_c_indent()
continue; continue;
} }
/* /* Skip preprocessor directives and blank lines. */
* Skip preprocessor directives and blank lines.
*/
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum)) if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum))
continue; continue;
/* Finally the actual check for "namespace". */
if (cin_is_cpp_namespace(l)) if (cin_is_cpp_namespace(l))
{ {
amount += ind_cpp_namespace; amount += ind_cpp_namespace - added_to_amount;
break; break;
} }
if (cin_nocode(l)) if (cin_nocode(l))
continue; continue;
} }
else if (lookfor != LOOKFOR_TERM
&& lookfor != LOOKFOR_CPP_BASECLASS)
{
amount = scope_amount;
if (theline[0] == '{')
amount += ind_open_extra;
} }
break; break;
} }

View File

@ -1308,6 +1308,20 @@ protected:
void testfall(); void testfall();
}; };
STARTTEST
:set cino=(0,gs,hs
2kdd]]=][
ENDTEST
class Foo : public Bar
{
public:
virtual void method1(void) = 0;
virtual void method2(int arg1,
int arg2,
int arg3) = 0;
};
STARTTEST STARTTEST
:set cino=+20 :set cino=+20
2kdd]]=][ 2kdd]]=][

View File

@ -1190,6 +1190,16 @@ protected:
}; };
class Foo : public Bar
{
public:
virtual void method1(void) = 0;
virtual void method2(int arg1,
int arg2,
int arg3) = 0;
};
void void
foo() foo()
{ {

View File

@ -709,6 +709,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
332,
/**/ /**/
331, 331,
/**/ /**/