mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 15:38:33 +00:00
Merge pull request #4262 from watiko/vim-7.4.893
vim-patch:7.4.{891,893,912}
This commit is contained in:
@@ -69,23 +69,33 @@ find_start_comment ( /* XXX */
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Find the start of a comment or raw string, not knowing if we are in a
|
||||||
* Find the start of a comment or raw string, not knowing if we are in a
|
/// comment or raw string right now.
|
||||||
* comment or raw string right now.
|
/// Search starts at w_cursor.lnum and goes backwards.
|
||||||
* Search starts at w_cursor.lnum and goes backwards.
|
///
|
||||||
* Return NULL when not inside a comment or raw string.
|
/// @returns NULL when not inside a comment or raw string.
|
||||||
* "CORS" -> Comment Or Raw String
|
///
|
||||||
*/
|
/// @note "CORS" -> Comment Or Raw String
|
||||||
static pos_T *ind_find_start_CORS(void)
|
static pos_T *ind_find_start_CORS(void)
|
||||||
{ /* XXX */
|
{
|
||||||
pos_T *comment_pos = find_start_comment(curbuf->b_ind_maxcomment);
|
// XXX
|
||||||
pos_T *rs_pos = find_start_rawstring(curbuf->b_ind_maxcomment);
|
static pos_T comment_pos_copy;
|
||||||
|
|
||||||
/* If comment_pos is before rs_pos the raw string is inside the comment.
|
pos_T *comment_pos = find_start_comment(curbuf->b_ind_maxcomment);
|
||||||
* If rs_pos is before comment_pos the comment is inside the raw string. */
|
if (comment_pos != NULL) {
|
||||||
if (comment_pos == NULL || (rs_pos != NULL && lt(*rs_pos, *comment_pos)))
|
// Need to make a copy of the static pos in findmatchlimit(),
|
||||||
return rs_pos;
|
// calling find_start_rawstring() may change it.
|
||||||
return comment_pos;
|
comment_pos_copy = *comment_pos;
|
||||||
|
comment_pos = &comment_pos_copy;
|
||||||
|
}
|
||||||
|
pos_T *rs_pos = find_start_rawstring(curbuf->b_ind_maxcomment);
|
||||||
|
|
||||||
|
// If comment_pos is before rs_pos the raw string is inside the comment.
|
||||||
|
// If rs_pos is before comment_pos the comment is inside the raw string.
|
||||||
|
if (comment_pos == NULL || (rs_pos != NULL && lt(*rs_pos, *comment_pos))) {
|
||||||
|
return rs_pos;
|
||||||
|
}
|
||||||
|
return comment_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -847,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)) {
|
||||||
@@ -1122,13 +1146,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;
|
||||||
@@ -2707,7 +2739,8 @@ int get_c_indent(void)
|
|||||||
|
|
||||||
if (terminated == 0 || (lookfor != LOOKFOR_UNTERM
|
if (terminated == 0 || (lookfor != LOOKFOR_UNTERM
|
||||||
&& terminated == ',')) {
|
&& terminated == ',')) {
|
||||||
if (*skipwhite(l) == '[' || l[STRLEN(l) - 1] == '[') {
|
if (lookfor != LOOKFOR_ENUM_OR_INIT
|
||||||
|
&& (*skipwhite(l) == '[' || l[STRLEN(l) - 1] == '[')) {
|
||||||
amount += ind_continuation;
|
amount += ind_continuation;
|
||||||
}
|
}
|
||||||
// If we're in the middle of a paren thing, Go back to the line
|
// If we're in the middle of a paren thing, Go back to the line
|
||||||
@@ -2915,34 +2948,35 @@ int get_c_indent(void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ignore unterminated lines in between, but
|
// Ignore unterminated lines in between, but
|
||||||
* reduce indent. */
|
// reduce indent.
|
||||||
if (amount > cur_amount)
|
if (amount > cur_amount) {
|
||||||
amount = cur_amount;
|
amount = cur_amount;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
// Found first unterminated line on a row, may
|
||||||
* Found first unterminated line on a row, may
|
// line up with this line, remember its indent
|
||||||
* line up with this line, remember its indent
|
// 100 + // NOLINT(whitespace/tab)
|
||||||
* 100 +
|
// -> here; // NOLINT(whitespace/tab)
|
||||||
* -> here;
|
|
||||||
*/
|
|
||||||
l = get_cursor_line_ptr();
|
l = get_cursor_line_ptr();
|
||||||
amount = cur_amount;
|
amount = cur_amount;
|
||||||
if (*skipwhite(l) == ']' || l[STRLEN(l) - 1] == ']') {
|
|
||||||
|
n = (int)STRLEN(l);
|
||||||
|
if (terminated == ','
|
||||||
|
&& (*skipwhite(l) == ']'
|
||||||
|
|| (n >=2 && l[n - 2] == ']'))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// If previous line ends in ',', check whether we
|
||||||
* If previous line ends in ',', check whether we
|
// are in an initialization or enum
|
||||||
* are in an initialization or enum
|
// struct xxx =
|
||||||
* struct xxx =
|
// {
|
||||||
* {
|
// sizeof a,
|
||||||
* sizeof a,
|
// 124 };
|
||||||
* 124 };
|
// or a normal possible continuation line.
|
||||||
* or a normal possible continuation line.
|
// but only, of no other statement has been found
|
||||||
* but only, of no other statement has been found
|
// yet.
|
||||||
* yet.
|
|
||||||
*/
|
|
||||||
if (lookfor == LOOKFOR_INITIAL && terminated == ',') {
|
if (lookfor == LOOKFOR_INITIAL && terminated == ',') {
|
||||||
if (curbuf->b_ind_js) {
|
if (curbuf->b_ind_js) {
|
||||||
// Search for a line ending in a comma
|
// Search for a line ending in a comma
|
||||||
|
@@ -378,7 +378,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,
|
||||||
@@ -397,9 +397,9 @@ static int included_patches[] = {
|
|||||||
// 896,
|
// 896,
|
||||||
895,
|
895,
|
||||||
// 894 NA
|
// 894 NA
|
||||||
// 893,
|
893,
|
||||||
// 892,
|
// 892,
|
||||||
// 891,
|
891,
|
||||||
// 890 NA
|
// 890 NA
|
||||||
// 889,
|
// 889,
|
||||||
888,
|
888,
|
||||||
|
@@ -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
|
||||||
@@ -919,6 +926,55 @@ describe('cindent', function()
|
|||||||
)foo";
|
)foo";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
int a[4] = {
|
||||||
|
[0] = 0,
|
||||||
|
[1] = 1,
|
||||||
|
[2] = 2,
|
||||||
|
[3] = 3,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
a = b[2]
|
||||||
|
+ 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
if (1)
|
||||||
|
/* aaaaa
|
||||||
|
* bbbbb
|
||||||
|
*/
|
||||||
|
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 */
|
||||||
]=])
|
]=])
|
||||||
|
|
||||||
@@ -1580,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
|
||||||
@@ -1825,6 +1888,55 @@ describe('cindent', function()
|
|||||||
)foo";
|
)foo";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
int a[4] = {
|
||||||
|
[0] = 0,
|
||||||
|
[1] = 1,
|
||||||
|
[2] = 2,
|
||||||
|
[3] = 3,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
a = b[2]
|
||||||
|
+ 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
if (1)
|
||||||
|
/* aaaaa
|
||||||
|
* bbbbb
|
||||||
|
*/
|
||||||
|
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)
|
||||||
|
Reference in New Issue
Block a user