aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2023-12-28 13:42:24 +0100
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2023-12-30 12:45:38 +0100
commitc89292fcb7f2ebf06efb7c1d00c28f34c6f68fec (patch)
treeb1257a572495337ca936c47839bb08aa45528c84 /src/nvim/edit.c
parentd634cd5b0bc3ac6bdf285432f74a1c10f12b6031 (diff)
downloadrneovim-c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec.tar.gz
rneovim-c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec.tar.bz2
rneovim-c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec.zip
refactor: follow style guide
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r--src/nvim/edit.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 8984a959d3..80e6648e95 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -112,7 +112,7 @@ static int did_restart_edit; // "restart_edit" when calling edit()
static bool can_cindent; // may do cindenting on this line
-static int revins_on; // reverse insert mode on
+static bool revins_on; // reverse insert mode on
static int revins_chars; // how much to skip after edit
static int revins_legal; // was the last char 'legal'?
static int revins_scol; // start column of revins session
@@ -1598,7 +1598,7 @@ void undisplay_dollar(void)
/// @param round if true, round the indent to 'shiftwidth' (only with _INC and _Dec).
/// @param replaced replaced character, put on replace stack
/// @param call_changed_bytes call changed_bytes()
-void change_indent(int type, int amount, int round, int replaced, int call_changed_bytes)
+void change_indent(int type, int amount, int round, int replaced, bool call_changed_bytes)
{
int insstart_less; // reduction for Insstart.col
colnr_T orig_col = 0; // init for GCC
@@ -1640,7 +1640,7 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang
// Set the new indent. The cursor will be put on the first non-blank.
if (type == INDENT_SET) {
- (void)set_indent(amount, call_changed_bytes ? SIN_CHANGED : 0);
+ set_indent(amount, call_changed_bytes ? SIN_CHANGED : 0);
} else {
int save_State = State;
@@ -2138,11 +2138,10 @@ void insertchar(int c, int flags, int second_indent)
&& !p_ri) {
#define INPUT_BUFLEN 100
char buf[INPUT_BUFLEN + 1];
- int i;
colnr_T virtcol = 0;
buf[0] = (char)c;
- i = 1;
+ int i = 1;
if (textwidth > 0) {
virtcol = get_nolist_virtcol();
}
@@ -2456,9 +2455,7 @@ void beginline(int flags)
curwin->w_cursor.coladd = 0;
if (flags & (BL_WHITE | BL_SOL)) {
- char *ptr;
-
- for (ptr = get_cursor_line_ptr(); ascii_iswhite(*ptr)
+ for (char *ptr = get_cursor_line_ptr(); ascii_iswhite(*ptr)
&& !((flags & BL_FIX) && ptr[1] == NUL); ptr++) {
curwin->w_cursor.col++;
}
@@ -2571,7 +2568,7 @@ void cursor_up_inner(win_T *wp, linenr_T n)
// Count each sequence of folded lines as one logical line.
// go to the start of the current fold
- (void)hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
+ hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
while (n--) {
// move up one line
@@ -2583,7 +2580,7 @@ void cursor_up_inner(win_T *wp, linenr_T n)
// Insert mode or when 'foldopen' contains "all": it will open
// in a moment.
if (n > 0 || !((State & MODE_INSERT) || (fdo_flags & FDO_ALL))) {
- (void)hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
+ hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
}
}
if (lnum < 1) {
@@ -2597,7 +2594,7 @@ void cursor_up_inner(win_T *wp, linenr_T n)
}
/// @param upd_topline When true: update topline
-int cursor_up(linenr_T n, int upd_topline)
+int cursor_up(linenr_T n, bool upd_topline)
{
// This fails if the cursor is already in the first line.
if (n > 0 && curwin->w_cursor.lnum <= 1) {
@@ -2650,7 +2647,7 @@ void cursor_down_inner(win_T *wp, int n)
}
/// @param upd_topline When true: update topline
-int cursor_down(int n, int upd_topline)
+int cursor_down(int n, bool upd_topline)
{
// This fails if the cursor is already in the last line.
if (n > 0 && curwin->w_cursor.lnum >= curwin->w_buffer->b_ml.ml_line_count) {
@@ -2947,7 +2944,7 @@ static void replace_do_bs(int limit_col)
getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL);
orig_vcols = win_chartabsize(curwin, get_cursor_pos_ptr(), start_vcol);
}
- (void)del_char_after_col(limit_col);
+ del_char_after_col(limit_col);
if (l_State & VREPLACE_FLAG) {
orig_len = (int)strlen(get_cursor_pos_ptr());
}
@@ -2978,7 +2975,7 @@ static void replace_do_bs(int limit_col)
// mark the buffer as changed and prepare for displaying
changed_bytes(curwin->w_cursor.lnum, curwin->w_cursor.col);
} else if (cc == 0) {
- (void)del_char_after_col(limit_col);
+ del_char_after_col(limit_col);
}
}
@@ -3005,8 +3002,8 @@ bool cindent_on(void)
bool in_cinkeys(int keytyped, int when, bool line_is_empty)
{
char *look;
- int try_match;
- int try_match_word;
+ bool try_match;
+ bool try_match_word;
char *p;
bool icase;
@@ -3412,7 +3409,7 @@ static bool ins_esc(int *count, int cmdchar, bool nomove)
State &= ~REPLACE_FLAG;
}
- (void)start_redo_ins();
+ start_redo_ins();
if (cmdchar == 'r' || cmdchar == 'v') {
stuffRedoReadbuff(ESC_STR); // No ESC in redo buffer
}
@@ -3602,7 +3599,7 @@ static void ins_shift(int c, int lastc)
if (c == Ctrl_D && (lastc == '0' || lastc == '^')
&& curwin->w_cursor.col > 0) {
curwin->w_cursor.col--;
- (void)del_char(false); // delete the '^' or '0'
+ del_char(false); // delete the '^' or '0'
// In Replace mode, restore the characters that '^' or '0' replaced.
if (State & REPLACE_FLAG) {
replace_pop_ins();
@@ -3667,7 +3664,7 @@ static void ins_bs_one(colnr_T *vcolp)
replace_do_bs(-1);
}
} else {
- (void)del_char(false);
+ del_char(false);
}
}
@@ -3708,7 +3705,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
if (stop_arrow() == FAIL) {
return false;
}
- int in_indent = inindent(0);
+ bool in_indent = inindent(0);
if (in_indent) {
can_cindent = false;
}
@@ -3766,9 +3763,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
if (has_format_option(FO_AUTO)
&& has_format_option(FO_WHITE_PAR)) {
char *ptr = ml_get_buf_mut(curbuf, curwin->w_cursor.lnum);
- int len;
-
- len = (int)strlen(ptr);
+ int len = (int)strlen(ptr);
if (len > 0 && ptr[len - 1] == ' ') {
ptr[len - 1] = NUL;
}
@@ -3918,7 +3913,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
char *p0 = get_cursor_pos_ptr();
has_composing = utf_composinglike(p0, p0 + utf_ptr2len(p0));
}
- (void)del_char(false);
+ del_char(false);
// If there are combining characters and 'delcombine' is set
// move the cursor back. Don't back up before the base character.
if (has_composing) {
@@ -4062,7 +4057,7 @@ static void ins_s_left(void)
if (!end_change) {
AppendCharToRedobuff(K_S_LEFT);
}
- (void)bck_word(1, false, false);
+ bck_word(1, false, false);
curwin->w_set_curswant = true;
} else {
vim_beep(BO_CRSR);
@@ -4121,7 +4116,7 @@ static void ins_s_right(void)
if (!end_change) {
AppendCharToRedobuff(K_S_RIGHT);
}
- (void)fwd_word(1, false, 0);
+ fwd_word(1, false, 0);
curwin->w_set_curswant = true;
} else {
vim_beep(BO_CRSR);
@@ -4234,7 +4229,7 @@ static bool ins_tab(void)
return false;
}
- int ind = inindent(0);
+ bool ind = inindent(0);
if (ind) {
can_cindent = false;
}
@@ -4657,7 +4652,7 @@ static void ins_try_si(int c)
if (State & VREPLACE_FLAG) {
change_indent(INDENT_SET, i, false, NUL, true);
} else {
- (void)set_indent(i, SIN_CHANGED);
+ set_indent(i, SIN_CHANGED);
}
} else if (curwin->w_cursor.col > 0) {
// when inserting '{' after "O" reduce indent, but not
@@ -4689,7 +4684,7 @@ static void ins_try_si(int c)
if (curwin->w_cursor.col > 0 && can_si && c == '#' && inindent(0)) {
// remember current indent for next line
old_indent = get_indent();
- (void)set_indent(0, SIN_CHANGED);
+ set_indent(0, SIN_CHANGED);
}
// Adjust ai_col, the char at this position can be deleted.