73
* Find the start of a comment or raw string, not knowing if we are in a
74
* comment or raw string right now.
75
* Search starts at w_cursor.lnum and goes backwards.
76
* Return NULL when not inside a comment or raw string.
77
* "CORS" -> Comment Or Raw String
72
/// Find the start of a comment or raw string, not knowing if we are in a
73
/// comment or raw string right now.
74
/// Search starts at w_cursor.lnum and goes backwards.
76
/// @returns NULL when not inside a comment or raw string.
78
/// @note "CORS" -> Comment Or Raw String
79
79
static pos_T *ind_find_start_CORS(void)
81
pos_T *comment_pos = find_start_comment(curbuf->b_ind_maxcomment);
82
pos_T *rs_pos = find_start_rawstring(curbuf->b_ind_maxcomment);
84
/* If comment_pos is before rs_pos the raw string is inside the comment.
85
* If rs_pos is before comment_pos the comment is inside the raw string. */
86
if (comment_pos == NULL || (rs_pos != NULL && lt(*rs_pos, *comment_pos)))
82
static pos_T comment_pos_copy;
84
pos_T *comment_pos = find_start_comment(curbuf->b_ind_maxcomment);
85
if (comment_pos != NULL) {
86
// Need to make a copy of the static pos in findmatchlimit(),
87
// calling find_start_rawstring() may change it.
88
comment_pos_copy = *comment_pos;
89
comment_pos = &comment_pos_copy;
91
pos_T *rs_pos = find_start_rawstring(curbuf->b_ind_maxcomment);
93
// If comment_pos is before rs_pos the raw string is inside the comment.
94
// If rs_pos is before comment_pos the comment is inside the raw string.
95
if (comment_pos == NULL || (rs_pos != NULL && lt(*rs_pos, *comment_pos))) {
849
859
while (*s && *s != '(' && *s != ';' && *s != '\'' && *s != '"') {
850
if (cin_iscomment(s)) /* ignore comments */
861
if (cin_iscomment(s)) {
851
862
s = cin_skipcomment(s);
856
return FALSE; /* ';', ' or " before any () or no '(' */
863
} else if (*s == ':') {
864
if (*(s + 1) == ':') {
867
// To avoid a mistake in the following situation:
868
// A::A(int a, int b)
869
// : a(0) // <--not a function decl
879
return false; // ';', ' or " before any () or no '('
858
882
while (*s && *s != ';' && *s != '\'' && *s != '"') {
859
883
if (*s == ')' && cin_nocode(s + 1)) {
1123
1147
pos->lnum = lnum;
1124
1148
line = ml_get(lnum);
1125
s = cin_skipcomment(line);
1127
1151
if (*s == NUL) {
1128
if (lnum == curwin->w_cursor.lnum)
1152
if (lnum == curwin->w_cursor.lnum) {
1130
/* Continue in the cursor line. */
1155
// Continue in the cursor line.
1131
1156
line = ml_get(++lnum);
1160
// don't recognize "case (foo):" as a baseclass */
1161
if (cin_iscase(s, false)) {
1132
1164
s = cin_skipcomment(line);
2708
2740
if (terminated == 0 || (lookfor != LOOKFOR_UNTERM
2709
2741
&& terminated == ',')) {
2710
if (*skipwhite(l) == '[' || l[STRLEN(l) - 1] == '[') {
2742
if (lookfor != LOOKFOR_ENUM_OR_INIT
2743
&& (*skipwhite(l) == '[' || l[STRLEN(l) - 1] == '[')) {
2711
2744
amount += ind_continuation;
2713
2746
// If we're in the middle of a paren thing, Go back to the line
2918
/* Ignore unterminated lines in between, but
2920
if (amount > cur_amount)
2951
// Ignore unterminated lines in between, but
2953
if (amount > cur_amount) {
2921
2954
amount = cur_amount;
2924
* Found first unterminated line on a row, may
2925
* line up with this line, remember its indent
2957
// Found first unterminated line on a row, may
2958
// line up with this line, remember its indent
2959
// 100 + // NOLINT(whitespace/tab)
2960
// -> here; // NOLINT(whitespace/tab)
2929
2961
l = get_cursor_line_ptr();
2930
2962
amount = cur_amount;
2931
if (*skipwhite(l) == ']' || l[STRLEN(l) - 1] == ']') {
2965
if (terminated == ','
2966
&& (*skipwhite(l) == ']'
2967
|| (n >=2 && l[n - 2] == ']'))) {
2936
* If previous line ends in ',', check whether we
2937
* are in an initialization or enum
2942
* or a normal possible continuation line.
2943
* but only, of no other statement has been found
2971
// If previous line ends in ',', check whether we
2972
// are in an initialization or enum
2977
// or a normal possible continuation line.
2978
// but only, of no other statement has been found
2946
2980
if (lookfor == LOOKFOR_INITIAL && terminated == ',') {
2947
2981
if (curbuf->b_ind_js) {
2948
2982
// Search for a line ending in a comma