patch 7.4.891
Problem: Indentation of array initializer is wrong.
Solution: Avoid that calling find_start_rawstring() changes the position
returned by find_start_comment(), add a test. (Hirohito Higashi)
diff --git a/src/misc1.c b/src/misc1.c
index 7eb3dce..60e8146 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -5345,8 +5345,19 @@
static pos_T *
ind_find_start_CORS() /* XXX */
{
- pos_T *comment_pos = find_start_comment(curbuf->b_ind_maxcomment);
- pos_T *rs_pos = find_start_rawstring(curbuf->b_ind_maxcomment);
+ static pos_T comment_pos_copy;
+ pos_T *comment_pos;
+ pos_T *rs_pos;
+
+ comment_pos = find_start_comment(curbuf->b_ind_maxcomment);
+ if (comment_pos != NULL)
+ {
+ /* Need to make a copy of the static pos in findmatchlimit(),
+ * calling find_start_rawstring() may change it. */
+ comment_pos_copy = *comment_pos;
+ comment_pos = &comment_pos_copy;
+ }
+ 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. */
@@ -8334,7 +8345,8 @@
if (terminated == 0 || (lookfor != LOOKFOR_UNTERM
&& terminated == ','))
{
- if (*skipwhite(l) == '[' || l[STRLEN(l) - 1] == '[')
+ if (lookfor != LOOKFOR_ENUM_OR_INIT &&
+ (*skipwhite(l) == '[' || l[STRLEN(l) - 1] == '['))
amount += ind_continuation;
/*
* if we're in the middle of a paren thing,
@@ -8576,7 +8588,10 @@
*/
l = ml_get_curline();
amount = cur_amount;
- if (*skipwhite(l) == ']' || l[STRLEN(l) - 1] == ']')
+
+ n = (int)STRLEN(l);
+ if (terminated == ',' && (*skipwhite(l) == ']'
+ || (n >=2 && l[n - 2] == ']')))
break;
/*
diff --git a/src/testdir/test3.in b/src/testdir/test3.in
index 4f5331e..4fc73a9 100644
--- a/src/testdir/test3.in
+++ b/src/testdir/test3.in
Binary files differ
diff --git a/src/testdir/test3.ok b/src/testdir/test3.ok
index e87e7fd..8fa9caa 100644
--- a/src/testdir/test3.ok
+++ b/src/testdir/test3.ok
@@ -898,6 +898,28 @@
)foo";
}
+{
+ int a[4] = {
+ [0] = 0,
+ [1] = 1,
+ [2] = 2,
+ [3] = 3,
+ };
+}
+
+{
+ a = b[2]
+ + 3;
+}
+
+{
+ if (1)
+ /* aaaaa
+ * bbbbb
+ */
+ a = 1;
+}
+
/* end of AUTO */
diff --git a/src/version.c b/src/version.c
index c60bbe6..ce05792 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 891,
+/**/
890,
/**/
889,