mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
updated for version 7.3.195
Problem: "} else" causes following lines to be indented too much. (Rouben Rostamian) Solution: Better detection for the "else". (Lech Lorens)
This commit is contained in:
10
src/misc1.c
10
src/misc1.c
@@ -5482,8 +5482,8 @@ cin_islinecomment(p)
|
|||||||
* Recognize a line that starts with '{' or '}', or ends with ';', ',', '{' or
|
* Recognize a line that starts with '{' or '}', or ends with ';', ',', '{' or
|
||||||
* '}'.
|
* '}'.
|
||||||
* Don't consider "} else" a terminated line.
|
* Don't consider "} else" a terminated line.
|
||||||
* Don't consider a line where there are unmatched opening braces before '}',
|
* If a line begins with an "else", only consider it terminated if no unmatched
|
||||||
* ';' or ',' a terminated line.
|
* opening braces follow (handle "else { foo();" correctly).
|
||||||
* Return the character terminating the line (ending char's have precedence if
|
* Return the character terminating the line (ending char's have precedence if
|
||||||
* both apply in order to determine initializations).
|
* both apply in order to determine initializations).
|
||||||
*/
|
*/
|
||||||
@@ -5495,19 +5495,23 @@ cin_isterminated(s, incl_open, incl_comma)
|
|||||||
{
|
{
|
||||||
char_u found_start = 0;
|
char_u found_start = 0;
|
||||||
unsigned n_open = 0;
|
unsigned n_open = 0;
|
||||||
|
int is_else = FALSE;
|
||||||
|
|
||||||
s = cin_skipcomment(s);
|
s = cin_skipcomment(s);
|
||||||
|
|
||||||
if (*s == '{' || (*s == '}' && !cin_iselse(s)))
|
if (*s == '{' || (*s == '}' && !cin_iselse(s)))
|
||||||
found_start = *s;
|
found_start = *s;
|
||||||
|
|
||||||
|
if (!found_start)
|
||||||
|
is_else = cin_iselse(s);
|
||||||
|
|
||||||
while (*s)
|
while (*s)
|
||||||
{
|
{
|
||||||
/* skip over comments, "" strings and 'c'haracters */
|
/* skip over comments, "" strings and 'c'haracters */
|
||||||
s = skip_string(cin_skipcomment(s));
|
s = skip_string(cin_skipcomment(s));
|
||||||
if (*s == '}' && n_open > 0)
|
if (*s == '}' && n_open > 0)
|
||||||
--n_open;
|
--n_open;
|
||||||
if (n_open == 0
|
if ((!is_else || n_open == 0)
|
||||||
&& (*s == ';' || *s == '}' || (incl_comma && *s == ','))
|
&& (*s == ';' || *s == '}' || (incl_comma && *s == ','))
|
||||||
&& cin_nocode(s + 1))
|
&& cin_nocode(s + 1))
|
||||||
return *s;
|
return *s;
|
||||||
|
@@ -1345,7 +1345,7 @@ func(int a
|
|||||||
, int c
|
, int c
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
STARTTEST
|
STARTTEST
|
||||||
@@ -1359,6 +1359,34 @@ void func(void)
|
|||||||
if(y==z)
|
if(y==z)
|
||||||
foo=1;
|
foo=1;
|
||||||
else { bar=1;
|
else { bar=1;
|
||||||
|
baz=2;
|
||||||
|
}
|
||||||
|
printf("Foo!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void func1(void)
|
||||||
|
{
|
||||||
|
char* tab[] = {"foo", "bar",
|
||||||
|
"baz", "quux",
|
||||||
|
"this line used", "to be indented incorrectly"};
|
||||||
|
foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void func2(void)
|
||||||
|
{
|
||||||
|
int tab[] =
|
||||||
|
{1, 2,
|
||||||
|
3, 4,
|
||||||
|
5, 6};
|
||||||
|
|
||||||
|
printf("This line used to be indented incorrectly.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void func3(void)
|
||||||
|
{
|
||||||
|
int tab[] = {
|
||||||
|
1, 2,
|
||||||
|
3, 4,
|
||||||
5, 6};
|
5, 6};
|
||||||
|
|
||||||
printf("Don't you dare indent this line incorrectly!\n);
|
printf("Don't you dare indent this line incorrectly!\n);
|
||||||
|
@@ -1216,6 +1216,34 @@ void func(void)
|
|||||||
printf("Foo!\n");
|
printf("Foo!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void func1(void)
|
||||||
|
{
|
||||||
|
char* tab[] = {"foo", "bar",
|
||||||
|
"baz", "quux",
|
||||||
|
"this line used", "to be indented incorrectly"};
|
||||||
|
foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void func2(void)
|
||||||
|
{
|
||||||
|
int tab[] =
|
||||||
|
{1, 2,
|
||||||
|
3, 4,
|
||||||
|
5, 6};
|
||||||
|
|
||||||
|
printf("This line used to be indented incorrectly.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void func3(void)
|
||||||
|
{
|
||||||
|
int tab[] = {
|
||||||
|
1, 2,
|
||||||
|
3, 4,
|
||||||
|
5, 6};
|
||||||
|
|
||||||
|
printf("Don't you dare indent this line incorrectly!\n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void func(void)
|
void func(void)
|
||||||
{
|
{
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
195,
|
||||||
/**/
|
/**/
|
||||||
194,
|
194,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user