@@ -5428,7 +5428,6 @@ static int skip_label(linenr_T, char_u **pp);
54285428static int cin_first_id_amount (void );
54295429static int cin_get_equal_amount (linenr_T lnum );
54305430static int cin_ispreproc (char_u * );
5431- static int cin_ispreproc_cont (char_u * * pp , linenr_T * lnump );
54325431static int cin_iscomment (char_u * );
54335432static int cin_islinecomment (char_u * );
54345433static int cin_isterminated (char_u * , int , int );
@@ -6008,13 +6007,18 @@ cin_ispreproc(char_u *s)
60086007 * Return TRUE if line "*pp" at "*lnump" is a preprocessor statement or a
60096008 * continuation line of a preprocessor statement. Decrease "*lnump" to the
60106009 * start and return the line in "*pp".
6010+ * Put the amount of indent in "*amount".
60116011 */
60126012 static int
6013- cin_ispreproc_cont (char_u * * pp , linenr_T * lnump )
6013+ cin_ispreproc_cont (char_u * * pp , linenr_T * lnump , int * amount )
60146014{
60156015 char_u * line = * pp ;
60166016 linenr_T lnum = * lnump ;
60176017 int retval = FALSE;
6018+ int candidate_amount = * amount ;
6019+
6020+ if (* line != NUL && line [STRLEN (line ) - 1 ] == '\\' )
6021+ candidate_amount = get_indent_lnum (lnum );
60186022
60196023 for (;;)
60206024 {
@@ -6033,6 +6037,8 @@ cin_ispreproc_cont(char_u **pp, linenr_T *lnump)
60336037
60346038 if (lnum != * lnump )
60356039 * pp = ml_get (* lnump );
6040+ if (retval )
6041+ * amount = candidate_amount ;
60366042 return retval ;
60376043}
60386044
@@ -7396,7 +7402,7 @@ get_c_indent(void)
73967402 l = skipwhite (ml_get (lnum ));
73977403 if (cin_nocode (l )) /* skip comment lines */
73987404 continue ;
7399- if (cin_ispreproc_cont (& l , & lnum ))
7405+ if (cin_ispreproc_cont (& l , & lnum , & amount ))
74007406 continue ; /* ignore #define, #if, etc. */
74017407 curwin -> w_cursor .lnum = lnum ;
74027408
@@ -7809,10 +7815,10 @@ get_c_indent(void)
78097815 */
78107816 if (curwin -> w_cursor .lnum <= ourscope )
78117817 {
7812- /* we reached end of scope:
7813- * if looking for a enum or structure initialization
7818+ /* We reached end of scope:
7819+ * If looking for a enum or structure initialization
78147820 * go further back:
7815- * if it is an initializer (enum xxx or xxx =), then
7821+ * If it is an initializer (enum xxx or xxx =), then
78167822 * don't add ind_continuation, otherwise it is a variable
78177823 * declaration:
78187824 * int x,
@@ -7851,7 +7857,8 @@ get_c_indent(void)
78517857 /*
78527858 * Skip preprocessor directives and blank lines.
78537859 */
7854- if (cin_ispreproc_cont (& l , & curwin -> w_cursor .lnum ))
7860+ if (cin_ispreproc_cont (& l , & curwin -> w_cursor .lnum ,
7861+ & amount ))
78557862 continue ;
78567863
78577864 if (cin_nocode (l ))
@@ -7968,7 +7975,8 @@ get_c_indent(void)
79687975 }
79697976
79707977 /* Skip preprocessor directives and blank lines. */
7971- if (cin_ispreproc_cont (& l , & curwin -> w_cursor .lnum ))
7978+ if (cin_ispreproc_cont (& l , & curwin -> w_cursor .lnum ,
7979+ & amount ))
79727980 continue ;
79737981
79747982 /* Finally the actual check for "namespace". */
@@ -8144,7 +8152,7 @@ get_c_indent(void)
81448152 * unlocked it)
81458153 */
81468154 l = ml_get_curline ();
8147- if (cin_ispreproc_cont (& l , & curwin -> w_cursor .lnum )
8155+ if (cin_ispreproc_cont (& l , & curwin -> w_cursor .lnum , & amount )
81488156 || cin_nocode (l ))
81498157 continue ;
81508158
@@ -8865,7 +8873,7 @@ get_c_indent(void)
88658873 /*
88668874 * Skip preprocessor directives and blank lines.
88678875 */
8868- if (cin_ispreproc_cont (& l , & curwin -> w_cursor .lnum ))
8876+ if (cin_ispreproc_cont (& l , & curwin -> w_cursor .lnum , & amount ))
88698877 continue ;
88708878
88718879 if (cin_nocode (l ))
@@ -8966,7 +8974,7 @@ get_c_indent(void)
89668974 {
89678975 look = ml_get (-- curwin -> w_cursor .lnum );
89688976 if (!(cin_nocode (look ) || cin_ispreproc_cont (
8969- & look , & curwin -> w_cursor .lnum )))
8977+ & look , & curwin -> w_cursor .lnum , & amount )))
89708978 break ;
89718979 }
89728980 if (curwin -> w_cursor .lnum > 0
0 commit comments