mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 17:36:29 +00:00
refactor: follow style guide
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user