Hi Bram and list, How to reproduce: - Run vanilla Vim with 'cindent'. $ vim -Nu NONE +"set cindent" - Input bellow. i#if aaa\<CR>bbb\<CR>ccc<ESC>
Expect behavior: #if aaa\ bbb\ ccc Actual behavior: #if aaa\ bbb\ ccc After the third line is not indent well. NOTE: This behavior occurs only outside of the curly bracket. I wrote a patch contains test. Sorry, it is still the old style test. I'll challenge it in this spring👍 Check it out. NOTE 2: This issue was reported by Ken Takata. -- Best regards, Hirohito Higashi (a.k.a. h_east) -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
diff --git a/src/misc1.c b/src/misc1.c index 3630d7b..1f16958 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,8 @@ 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 +7969,8 @@ 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 +8146,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 +8867,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 +8968,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 diff --git a/src/testdir/test3.in b/src/testdir/test3.in index 096f152..e8648d3 100644 --- a/src/testdir/test3.in +++ b/src/testdir/test3.in @@ -2318,6 +2318,25 @@ i; JSEND STARTTEST +:set cin cino& +/start of define +=/end of define +ENDTEST + +/* start of define */ +{ +} +#define AAA \ +BBB\ +CCC + +#define CNT \ +1 + \ +2 + \ +4 +/* end of define */ + +STARTTEST :g/^STARTTEST/.,/^ENDTEST/d :1;/start of AUTO/,$wq! test.out ENDTEST diff --git a/src/testdir/test3.ok b/src/testdir/test3.ok index 2f9572c..cfb519b 100644 --- a/src/testdir/test3.ok +++ b/src/testdir/test3.ok @@ -2080,3 +2080,17 @@ var a, i; JSEND + +/* start of define */ +{ +} +#define AAA \ + BBB\ + CCC + +#define CNT \ + 1 + \ + 2 + \ + 4 +/* end of define */ +