Skip to content

Instantly share code, notes, and snippets.

@h-east
Created January 2, 2017 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h-east/ebac02153db3c4f7cc57dc6b260231cb to your computer and use it in GitHub Desktop.
Save h-east/ebac02153db3c4f7cc57dc6b260231cb to your computer and use it in GitHub Desktop.
diff --git a/src/misc1.c b/src/misc1.c
index 3630d7b..5795dbf 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -5422,7 +5422,7 @@ static int skip_label(linenr_T, char_u **pp);
static int cin_first_id_amount(void);
static int cin_get_equal_amount(linenr_T lnum);
static int cin_ispreproc(char_u *);
-static int cin_ispreproc_cont(char_u **pp, linenr_T *lnump);
+static int cin_ispreproc_cont(char_u **pp, linenr_T *lnump, int *amount);
static int cin_iscomment(char_u *);
static int cin_islinecomment(char_u *);
static int cin_isterminated(char_u *, int, int);
@@ -6004,11 +6004,15 @@ cin_ispreproc(char_u *s)
* start and return the line in "*pp".
*/
static int
-cin_ispreproc_cont(char_u **pp, linenr_T *lnump)
+cin_ispreproc_cont(char_u **pp, linenr_T *lnump, int *amount)
{
char_u *line = *pp;
linenr_T lnum = *lnump;
int retval = FALSE;
+ int candidate_amount = *amount;
+
+ if (*line != NUL && line[STRLEN(line) - 1] == '\\')
+ candidate_amount = get_indent_lnum(lnum);
for (;;)
{
@@ -6027,6 +6031,8 @@ cin_ispreproc_cont(char_u **pp, linenr_T *lnump)
if (lnum != *lnump)
*pp = ml_get(*lnump);
+ if (retval)
+ *amount = candidate_amount;
return retval;
}
@@ -7390,7 +7396,7 @@ get_c_indent(void)
l = skipwhite(ml_get(lnum));
if (cin_nocode(l)) /* skip comment lines */
continue;
- if (cin_ispreproc_cont(&l, &lnum))
+ if (cin_ispreproc_cont(&l, &lnum, &amount))
continue; /* ignore #define, #if, etc. */
curwin->w_cursor.lnum = lnum;
@@ -7845,7 +7851,7 @@ get_c_indent(void)
/*
* Skip preprocessor directives and blank lines.
*/
- if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum))
+ if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount))
continue;
if (cin_nocode(l))
@@ -7962,7 +7968,7 @@ get_c_indent(void)
}
/* Skip preprocessor directives and blank lines. */
- if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum))
+ if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount))
continue;
/* Finally the actual check for "namespace". */
@@ -8138,7 +8144,7 @@ get_c_indent(void)
* unlocked it)
*/
l = ml_get_curline();
- if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum)
+ if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)
|| cin_nocode(l))
continue;
@@ -8859,7 +8865,7 @@ term_again:
/*
* Skip preprocessor directives and blank lines.
*/
- if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum))
+ if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount))
continue;
if (cin_nocode(l))
@@ -8960,7 +8966,7 @@ term_again:
{
look = ml_get(--curwin->w_cursor.lnum);
if (!(cin_nocode(look) || cin_ispreproc_cont(
- &look, &curwin->w_cursor.lnum)))
+ &look, &curwin->w_cursor.lnum, &amount)))
break;
}
if (curwin->w_cursor.lnum > 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment