mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 22:18:33 +00:00
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:
@@ -1132,13 +1132,21 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached) {
|
||||
|
||||
pos->lnum = lnum;
|
||||
line = ml_get(lnum);
|
||||
s = cin_skipcomment(line);
|
||||
s = line;
|
||||
for (;; ) {
|
||||
if (*s == NUL) {
|
||||
if (lnum == curwin->w_cursor.lnum)
|
||||
if (lnum == curwin->w_cursor.lnum) {
|
||||
break;
|
||||
/* Continue in the cursor line. */
|
||||
}
|
||||
// Continue in the cursor line.
|
||||
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);
|
||||
if (*s == NUL)
|
||||
continue;
|
||||
|
@@ -395,7 +395,7 @@ static int included_patches[] = {
|
||||
// 896,
|
||||
// 895,
|
||||
// 894 NA
|
||||
// 893,
|
||||
893,
|
||||
// 892,
|
||||
891,
|
||||
// 890 NA
|
||||
|
@@ -941,6 +941,33 @@ describe('cindent', function()
|
||||
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 */
|
||||
]=])
|
||||
|
||||
@@ -1869,6 +1896,33 @@ describe('cindent', function()
|
||||
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)
|
||||
|
Reference in New Issue
Block a user