mirror of
https://github.com/neovim/neovim.git
synced 2026-04-22 15:25:30 +00:00
vim-patch:9.1.1877: cindent: wrong indentation after an array declaration (#36340)
Problem: cindent: wrong indentation after an array declaration
Solution: check if the filetype if javascript before matching the syntax
(Anttoni Erkkilä)
cindent matches a javascript syntax for C files causing wrong
indentation in the following case:
```
void foo() {
float a[5],
b;
}
```
closes: vim/vim#18631
61ef8a3db9
Co-authored-by: Anttoni Erkkilä <anttoni.erkkila@protonmail.com>
This commit is contained in:
@@ -3179,9 +3179,8 @@ int get_c_indent(void)
|
|||||||
amount = cur_amount;
|
amount = cur_amount;
|
||||||
|
|
||||||
n = (int)strlen(l);
|
n = (int)strlen(l);
|
||||||
if (terminated == ','
|
if (curbuf->b_ind_js && terminated == ','
|
||||||
&& (*skipwhite(l) == ']'
|
&& (*skipwhite(l) == ']' || (n >= 2 && l[n - 2] == ']'))) {
|
||||||
|| (n >= 2 && l[n - 2] == ']'))) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1101,6 +1101,11 @@ func Test_cindent_1()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void foo() {
|
||||||
|
float a[5],
|
||||||
|
b;
|
||||||
|
}
|
||||||
|
|
||||||
/* end of AUTO */
|
/* end of AUTO */
|
||||||
[CODE]
|
[CODE]
|
||||||
|
|
||||||
@@ -2078,6 +2083,11 @@ func Test_cindent_1()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void foo() {
|
||||||
|
float a[5],
|
||||||
|
b;
|
||||||
|
}
|
||||||
|
|
||||||
/* end of AUTO */
|
/* end of AUTO */
|
||||||
|
|
||||||
[CODE]
|
[CODE]
|
||||||
|
|||||||
Reference in New Issue
Block a user