mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 21:48:35 +00:00
vim-patch:7.4.912
Problem: Wrong indenting for C++ constructor.
Solution: Recognize ::. (Anhong)
e01f4f86ce
This commit is contained in:
@@ -857,13 +857,27 @@ static int cin_isfuncdecl(char_u **sp, linenr_T first_lnum, linenr_T min_lnum)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
while (*s && *s != '(' && *s != ';' && *s != '\'' && *s != '"') {
|
while (*s && *s != '(' && *s != ';' && *s != '\'' && *s != '"') {
|
||||||
if (cin_iscomment(s)) /* ignore comments */
|
// ignore comments
|
||||||
|
if (cin_iscomment(s)) {
|
||||||
s = cin_skipcomment(s);
|
s = cin_skipcomment(s);
|
||||||
else
|
} else if (*s == ':') {
|
||||||
++s;
|
if (*(s + 1) == ':') {
|
||||||
|
s += 2;
|
||||||
|
} else {
|
||||||
|
// To avoid a mistake in the following situation:
|
||||||
|
// A::A(int a, int b)
|
||||||
|
// : a(0) // <--not a function decl
|
||||||
|
// , b(0)
|
||||||
|
// {...
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (*s != '(') {
|
||||||
|
return false; // ';', ' or " before any () or no '('
|
||||||
}
|
}
|
||||||
if (*s != '(')
|
|
||||||
return FALSE; /* ';', ' or " before any () or no '(' */
|
|
||||||
|
|
||||||
while (*s && *s != ';' && *s != '\'' && *s != '"') {
|
while (*s && *s != ';' && *s != '\'' && *s != '"') {
|
||||||
if (*s == ')' && cin_nocode(s + 1)) {
|
if (*s == ')' && cin_nocode(s + 1)) {
|
||||||
|
@@ -376,7 +376,7 @@ static int included_patches[] = {
|
|||||||
915,
|
915,
|
||||||
// 914,
|
// 914,
|
||||||
// 913 NA
|
// 913 NA
|
||||||
// 912,
|
912,
|
||||||
// 911 NA
|
// 911 NA
|
||||||
// 910 NA
|
// 910 NA
|
||||||
// 909,
|
// 909,
|
||||||
|
@@ -674,6 +674,13 @@ describe('cindent', function()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
A::A(int a, int b)
|
||||||
|
: aa(a),
|
||||||
|
bb(b),
|
||||||
|
cc(c)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
class CAbc :
|
class CAbc :
|
||||||
public BaseClass1,
|
public BaseClass1,
|
||||||
protected BaseClass2
|
protected BaseClass2
|
||||||
@@ -1629,6 +1636,13 @@ describe('cindent', function()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
A::A(int a, int b)
|
||||||
|
: aa(a),
|
||||||
|
bb(b),
|
||||||
|
cc(c)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
class CAbc :
|
class CAbc :
|
||||||
public BaseClass1,
|
public BaseClass1,
|
||||||
protected BaseClass2
|
protected BaseClass2
|
||||||
|
Reference in New Issue
Block a user