diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-01-31 15:44:54 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-01-31 15:44:54 +0800 |
commit | eda957db10e97b28a2734e0391d986676927d963 (patch) | |
tree | 1252a8a9d7978a42b6605db431ffeca5007021fb /src/nvim/edit.c | |
parent | ef5cd99df0e00ee5dc91bd1b2b0e5fe1e346cbd1 (diff) | |
download | rneovim-eda957db10e97b28a2734e0391d986676927d963.tar.gz rneovim-eda957db10e97b28a2734e0391d986676927d963.tar.bz2 rneovim-eda957db10e97b28a2734e0391d986676927d963.zip |
vim-patch:8.2.3787: no proper formatting of a C line comment after a statement
Problem: No proper formatting of a C line comment after a statement.
Solution: Find the start of the line comment, insert the comment leader and
indent the comment properly.
https://github.com/vim/vim/commit/6e371ecb27227ff8fedd8561d0f3880a17576848
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r-- | src/nvim/edit.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 095fa14752..47e1cc3351 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -6021,6 +6021,7 @@ static void internal_format(int textwidth, int second_indent, int flags, int for char_u *saved_text = NULL; colnr_T col; colnr_T end_col; + bool did_do_comment = false; virtcol = get_nolist_virtcol() + char2cells(c != NUL ? c : gchar_cursor()); @@ -6294,11 +6295,18 @@ static void internal_format(int textwidth, int second_indent, int flags, int for + (fo_white_par ? OPENLINE_KEEPTRAIL : 0) + (do_comments ? OPENLINE_DO_COM : 0) + ((flags & INSCHAR_COM_LIST) ? OPENLINE_COM_LIST : 0), - ((flags & INSCHAR_COM_LIST) ? second_indent : old_indent)); + ((flags & INSCHAR_COM_LIST) ? second_indent : old_indent), + &did_do_comment); if (!(flags & INSCHAR_COM_LIST)) { old_indent = 0; } + // If a comment leader was inserted, may also do this on a following + // line. + if (did_do_comment) { + no_leader = false; + } + replace_offset = 0; if (first_line) { if (!(flags & INSCHAR_COM_LIST)) { @@ -9183,7 +9191,7 @@ static bool ins_eol(int c) AppendToRedobuff(NL_STR); bool i = open_line(FORWARD, has_format_option(FO_RET_COMS) ? OPENLINE_DO_COM : 0, - old_indent); + old_indent, NULL); old_indent = 0; can_cindent = true; // When inserting a line the cursor line must never be in a closed fold. |