diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/change.c | 3 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 5 | ||||
-rw-r--r-- | src/nvim/testdir/test_textformat.vim | 12 |
3 files changed, 17 insertions, 3 deletions
diff --git a/src/nvim/change.c b/src/nvim/change.c index bbb10d3a52..426310488a 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -1186,7 +1186,8 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment) end_comment_pending = NUL; if (flags & OPENLINE_DO_COM) { lead_len = get_leader_len(saved_line, &lead_flags, dir == BACKWARD, true); - if (lead_len == 0 && curbuf->b_p_cin && do_cindent && dir == FORWARD) { + if (lead_len == 0 && curbuf->b_p_cin && do_cindent && dir == FORWARD + && !has_format_option(FO_NO_OPEN_COMS)) { // Check for a line comment after code. comment_start = check_linecomment(saved_line); if (comment_start != MAXCOL) { diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 7ec53de2b5..d90ed6812c 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -67,6 +67,7 @@ #define FO_WRAP_COMS 'c' #define FO_RET_COMS 'r' #define FO_OPEN_COMS 'o' +#define FO_NO_OPEN_COMS '/' #define FO_Q_COMS 'q' #define FO_Q_NUMBER 'n' #define FO_Q_SECOND '2' @@ -85,7 +86,7 @@ #define DFLT_FO_VI "vt" #define DFLT_FO_VIM "tcqj" -#define FO_ALL "tcroq2vlb1mMBn,aw]jp" // for do_set() +#define FO_ALL "tcro/q2vlb1mMBn,aw]jp" // for do_set() // characters for the p_cpo option: #define CPO_ALTREAD 'a' // ":read" sets alternate file name @@ -118,7 +119,7 @@ #define CPO_REMMARK 'R' // remove marks when filtering #define CPO_BUFOPT 's' #define CPO_BUFOPTGLOB 'S' -#define CPO_TAGPAT 't' +#define CPO_TAGPAT 't' // tag pattern is used for "n" #define CPO_UNDO 'u' // "u" undoes itself #define CPO_BACKSPACE 'v' // "v" keep deleted text #define CPO_FWRITE 'W' // "w!" doesn't overwrite readonly files diff --git a/src/nvim/testdir/test_textformat.vim b/src/nvim/testdir/test_textformat.vim index b6be3d8861..714539d418 100644 --- a/src/nvim/testdir/test_textformat.vim +++ b/src/nvim/testdir/test_textformat.vim @@ -278,6 +278,18 @@ func Test_format_c_comment() // END call assert_equal(expected, getline(1, '$')) + 3delete + + " No comment repeated with a slash in 'formatoptions' + set fo+=/ + normal 2Gox + let expected =<< trim END + nop; + val = val; // This is a comment + x + END + call assert_equal(expected, getline(1, '$')) + set fo-=/ " using 'indentexpr' instead of 'cindent' does not repeat a comment setl nocindent indentexpr=2 |