diff options
author | dundargoc <gocdundar@gmail.com> | 2023-12-28 13:42:24 +0100 |
---|---|---|
committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2023-12-30 12:45:38 +0100 |
commit | c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec (patch) | |
tree | b1257a572495337ca936c47839bb08aa45528c84 /src/nvim/textformat.c | |
parent | d634cd5b0bc3ac6bdf285432f74a1c10f12b6031 (diff) | |
download | rneovim-c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec.tar.gz rneovim-c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec.tar.bz2 rneovim-c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec.zip |
refactor: follow style guide
Diffstat (limited to 'src/nvim/textformat.c')
-rw-r--r-- | src/nvim/textformat.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c index 7803322439..509a88e441 100644 --- a/src/nvim/textformat.c +++ b/src/nvim/textformat.c @@ -77,7 +77,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on bool first_line = true; colnr_T leader_len; bool no_leader = false; - int do_comments = (flags & INSCHAR_DO_COM); + bool do_comments = (flags & INSCHAR_DO_COM); int has_lbr = curwin->w_p_lbr; // make sure win_lbr_chartabsize() counts correctly @@ -100,15 +100,12 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on int wantcol; // column at textwidth border int foundcol; // column for start of spaces int end_foundcol = 0; // column for start of word - colnr_T virtcol; int orig_col = 0; char *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()); + colnr_T virtcol = get_nolist_virtcol() + char2cells(c != NUL ? c : gchar_cursor()); if (virtcol <= (colnr_T)textwidth) { break; } @@ -175,7 +172,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on } if (WHITECHAR(cc)) { // remember position of blank just before text - end_col = curwin->w_cursor.col; + colnr_T end_col = curwin->w_cursor.col; // find start of sequence of blanks int wcc = 0; // counter for whitespace chars @@ -419,7 +416,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on ins_str(" "); } } else { - (void)set_indent(second_indent, SIN_CHANGED); + set_indent(second_indent, SIN_CHANGED); } } } @@ -472,9 +469,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on static int fmt_check_par(linenr_T lnum, int *leader_len, char **leader_flags, bool do_comments) { char *flags = NULL; // init for GCC - char *ptr; - - ptr = ml_get(lnum); + char *ptr = ml_get(lnum); if (do_comments) { *leader_len = get_leader_len(ptr, leader_flags, false, true); } else { @@ -624,8 +619,6 @@ static bool paragraph_start(linenr_T lnum) /// @param prev_line may start in previous line void auto_format(bool trailblank, bool prev_line) { - char *linep; - if (!has_format_option(FO_AUTO)) { return; } @@ -694,7 +687,7 @@ void auto_format(bool trailblank, bool prev_line) // need to add a space when 'w' is in 'formatoptions' to keep a paragraph // formatted. if (!wasatend && has_format_option(FO_WHITE_PAR)) { - linep = get_cursor_line_ptr(); + char *linep = get_cursor_line_ptr(); colnr_T len = (colnr_T)strlen(linep); if (curwin->w_cursor.col == len) { char *plinep = xstrnsave(linep, (size_t)len + 2); @@ -1052,7 +1045,7 @@ void format_lines(linenr_T line_count, bool avoid_fex) indent = get_indent(); } } - (void)set_indent(indent, SIN_CHANGED); + set_indent(indent, SIN_CHANGED); } // put cursor on last non-space @@ -1096,13 +1089,13 @@ void format_lines(linenr_T line_count, bool avoid_fex) break; } if (next_leader_len > 0) { - (void)del_bytes(next_leader_len, false, false); + del_bytes(next_leader_len, false, false); mark_col_adjust(curwin->w_cursor.lnum, 0, 0, -next_leader_len, 0); } else if (second_indent > 0) { // the "leader" for FO_Q_SECOND int indent = (int)getwhitecols_curline(); if (indent > 0) { - (void)del_bytes(indent, false, false); + del_bytes(indent, false, false); mark_col_adjust(curwin->w_cursor.lnum, 0, 0, -indent, 0); } } |