mirror of
https://github.com/vim/vim.git
synced 2025-10-03 05:14:07 -04:00
updated for version 7.3.201
Problem: "} else" still causes following lines to be indented too much. Solution: Better detection for the "else" block. (Lech Lorens)
This commit is contained in:
22
src/misc1.c
22
src/misc1.c
@@ -7541,17 +7541,25 @@ get_c_indent()
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* When searching for a terminated line, don't use the
|
* When searching for a terminated line, don't use the
|
||||||
* one between the "if" and the "else".
|
* one between the "if" and the matching "else".
|
||||||
* Need to use the scope of this "else". XXX
|
* Need to use the scope of this "else". XXX
|
||||||
* If whilelevel != 0 continue looking for a "do {".
|
* If whilelevel != 0 continue looking for a "do {".
|
||||||
*/
|
*/
|
||||||
if (cin_iselse(l)
|
if (cin_iselse(l) && whilelevel == 0)
|
||||||
&& whilelevel == 0
|
{
|
||||||
&& ((trypos = find_start_brace(ind_maxcomment))
|
/* If we're looking at "} else", let's make sure we
|
||||||
== NULL
|
* find the opening brace of the enclosing scope,
|
||||||
|
* not the one from "if () {". */
|
||||||
|
if (*l == '}')
|
||||||
|
curwin->w_cursor.col =
|
||||||
|
(l - ml_get_curline()) + 1;
|
||||||
|
|
||||||
|
if ((trypos = find_start_brace(ind_maxcomment))
|
||||||
|
== NULL
|
||||||
|| find_match(LOOKFOR_IF, trypos->lnum,
|
|| find_match(LOOKFOR_IF, trypos->lnum,
|
||||||
ind_maxparen, ind_maxcomment) == FAIL))
|
ind_maxparen, ind_maxcomment) == FAIL)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1412,6 +1412,21 @@ void func(void)
|
|||||||
|
|
||||||
void func(void)
|
void func(void)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* This is a comment.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
STARTTEST
|
||||||
|
:set cino&
|
||||||
|
2kdd=][
|
||||||
|
ENDTEST
|
||||||
|
|
||||||
|
void func(void)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 10; ++i)
|
||||||
|
if (i & 1) {
|
||||||
|
foo(1);
|
||||||
} else
|
} else
|
||||||
foo(0);
|
foo(0);
|
||||||
baz();
|
baz();
|
||||||
|
@@ -1262,3 +1262,14 @@ void func(void)
|
|||||||
foo();
|
foo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void func(void)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 10; ++i)
|
||||||
|
if (i & 1) {
|
||||||
|
foo(1);
|
||||||
|
} else
|
||||||
|
foo(0);
|
||||||
|
baz();
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
201,
|
||||||
/**/
|
/**/
|
||||||
200,
|
200,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user