vim-patch:7.4.893

Problem:    C indenting is wrong below a "case (foo):" because it is
            recognized as a C++ base class construct.  Issue #38.
Solution:   Check for the case keyword.

d1b15dec4d
This commit is contained in:
watiko
2016-02-15 19:12:47 +09:00
parent 2d5cba630c
commit 72d5a88af5
3 changed files with 66 additions and 4 deletions

View File

@@ -1132,13 +1132,21 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached) {
pos->lnum = lnum; pos->lnum = lnum;
line = ml_get(lnum); line = ml_get(lnum);
s = cin_skipcomment(line); s = line;
for (;; ) { for (;; ) {
if (*s == NUL) { if (*s == NUL) {
if (lnum == curwin->w_cursor.lnum) if (lnum == curwin->w_cursor.lnum) {
break; break;
/* Continue in the cursor line. */ }
// Continue in the cursor line.
line = ml_get(++lnum); line = ml_get(++lnum);
s = line;
}
if (s == line) {
// don't recognize "case (foo):" as a baseclass */
if (cin_iscase(s, false)) {
break;
}
s = cin_skipcomment(line); s = cin_skipcomment(line);
if (*s == NUL) if (*s == NUL)
continue; continue;

View File

@@ -395,7 +395,7 @@ static int included_patches[] = {
// 896, // 896,
// 895, // 895,
// 894 NA // 894 NA
// 893, 893,
// 892, // 892,
891, 891,
// 890 NA // 890 NA

View File

@@ -941,6 +941,33 @@ describe('cindent', function()
a = 1; a = 1;
} }
void func()
{
switch (foo)
{
case (bar):
if (baz())
quux();
break;
case (shmoo):
if (!bar)
{
}
case (foo1):
switch (bar)
{
case baz:
baz_f();
break;
}
break;
default:
baz();
baz();
break;
}
}
/* end of AUTO */ /* end of AUTO */
]=]) ]=])
@@ -1869,6 +1896,33 @@ describe('cindent', function()
a = 1; a = 1;
} }
void func()
{
switch (foo)
{
case (bar):
if (baz())
quux();
break;
case (shmoo):
if (!bar)
{
}
case (foo1):
switch (bar)
{
case baz:
baz_f();
break;
}
break;
default:
baz();
baz();
break;
}
}
/* end of AUTO */ /* end of AUTO */
]=]) ]=])
end) end)