patch 8.2.4911: the mode #defines are not clearly named
Problem: The mode #defines are not clearly named.
Solution: Prepend MODE_. Renumber them to put the mapped modes first.
diff --git a/src/indent.c b/src/indent.c
index e8892b5..0666f0e 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -828,7 +828,7 @@
pos.lnum = 0;
// In format_lines() (i.e. not insert mode), fo+=q is needed too...
- if ((State & INSERT) || has_format_option(FO_Q_COMS))
+ if ((State & MODE_INSERT) || has_format_option(FO_Q_COMS))
lead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE);
regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC);
@@ -1276,7 +1276,7 @@
colnr_T orig_col = 0; // init for GCC
char_u *new_line, *orig_line = NULL; // init for GCC
- // VREPLACE mode needs to know what the line was like before changing
+ // MODE_VREPLACE state needs to know what the line was like before changing
if (State & VREPLACE_FLAG)
{
orig_line = vim_strsave(ml_get_curline()); // Deal with NULL below
@@ -1318,7 +1318,7 @@
// Avoid being called recursively.
if (State & VREPLACE_FLAG)
- State = INSERT;
+ State = MODE_INSERT;
shift_line(type == INDENT_DEC, round, 1, call_changed_bytes);
State = save_State;
}
@@ -1339,7 +1339,7 @@
insstart_less = MAXCOL;
new_cursor_col += curwin->w_cursor.col;
}
- else if (!(State & INSERT))
+ else if (!(State & MODE_INSERT))
new_cursor_col = curwin->w_cursor.col;
else
{
@@ -1397,7 +1397,7 @@
changed_cline_bef_curs();
// May have to adjust the start of the insert.
- if (State & INSERT)
+ if (State & MODE_INSERT)
{
if (curwin->w_cursor.lnum == Insstart.lnum && Insstart.col != 0)
{
@@ -1412,9 +1412,9 @@
ai_col -= insstart_less;
}
- // For REPLACE mode, may have to fix the replace stack, if it's possible.
- // If the number of characters before the cursor decreased, need to pop a
- // few characters from the replace stack.
+ // For MODE_REPLACE state, may have to fix the replace stack, if it's
+ // possible. If the number of characters before the cursor decreased, need
+ // to pop a few characters from the replace stack.
// If the number of characters before the cursor increased, need to push a
// few NULs onto the replace stack.
if (REPLACE_NORMAL(State) && start_col >= 0)
@@ -1436,9 +1436,9 @@
}
}
- // For VREPLACE mode, we also have to fix the replace stack. In this case
- // it is always possible because we backspace over the whole line and then
- // put it back again the way we wanted it.
+ // For MODE_VREPLACE state, we also have to fix the replace stack. In this
+ // case it is always possible because we backspace over the whole line and
+ // then put it back again the way we wanted it.
if (State & VREPLACE_FLAG)
{
// If orig_line didn't allocate, just return. At least we did the job,
@@ -1894,7 +1894,7 @@
// Pretend to be in Insert mode, allow cursor past end of line for "o"
// command.
save_State = State;
- State = INSERT;
+ State = MODE_INSERT;
curwin->w_cursor = save_pos;
curwin->w_curswant = save_curswant;
curwin->w_set_curswant = save_set_curswant;