misc: fixpos in del_char() is bool

This commit is contained in:
Jan Edmund Lazo
2018-08-07 19:07:54 -04:00
parent 0e4a54a17b
commit d5e8b3f451
4 changed files with 35 additions and 32 deletions

View File

@@ -5807,7 +5807,7 @@ static void check_auto_format(
} }
if (c != NUL) { if (c != NUL) {
// The space is no longer at the end of the line, delete it. // The space is no longer at the end of the line, delete it.
del_char(FALSE); del_char(false);
did_add_space = false; did_add_space = false;
} }
} }
@@ -6053,10 +6053,12 @@ stop_insert (
if (gchar_cursor() == NUL && curwin->w_cursor.col > 0) if (gchar_cursor() == NUL && curwin->w_cursor.col > 0)
--curwin->w_cursor.col; --curwin->w_cursor.col;
cc = gchar_cursor(); cc = gchar_cursor();
if (!ascii_iswhite(cc)) if (!ascii_iswhite(cc)) {
break; break;
if (del_char(TRUE) == FAIL) }
break; /* should not happen */ if (del_char(true) == FAIL) {
break; // should not happen
}
} }
if (curwin->w_cursor.lnum != tpos.lnum) if (curwin->w_cursor.lnum != tpos.lnum)
curwin->w_cursor = tpos; curwin->w_cursor = tpos;
@@ -6710,8 +6712,8 @@ static void replace_do_bs(int limit_col)
* text aligned. */ * text aligned. */
curwin->w_cursor.col += ins_len; curwin->w_cursor.col += ins_len;
while (vcol > orig_vcols && gchar_cursor() == ' ') { while (vcol > orig_vcols && gchar_cursor() == ' ') {
del_char(FALSE); del_char(false);
++orig_vcols; orig_vcols++;
} }
curwin->w_cursor.col -= ins_len; curwin->w_cursor.col -= ins_len;
} }
@@ -7453,13 +7455,15 @@ static void ins_shift(int c, int lastc)
*/ */
if (c == Ctrl_D && (lastc == '0' || lastc == '^') if (c == Ctrl_D && (lastc == '0' || lastc == '^')
&& curwin->w_cursor.col > 0) { && curwin->w_cursor.col > 0) {
--curwin->w_cursor.col; curwin->w_cursor.col--;
(void)del_char(FALSE); /* delete the '^' or '0' */ (void)del_char(false); // delete the '^' or '0'
/* In Replace mode, restore the characters that '^' or '0' replaced. */ // In Replace mode, restore the characters that '^' or '0' replaced.
if (State & REPLACE_FLAG) if (State & REPLACE_FLAG) {
replace_pop_ins(); replace_pop_ins();
if (lastc == '^') }
old_indent = get_indent(); /* remember curr. indent */ if (lastc == '^') {
old_indent = get_indent(); // remember curr. indent
}
change_indent(INDENT_SET, 0, TRUE, 0, TRUE); change_indent(INDENT_SET, 0, TRUE, 0, TRUE);
} else } else
change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, TRUE, 0, TRUE); change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, TRUE, 0, TRUE);
@@ -7517,8 +7521,9 @@ static void ins_bs_one(colnr_T *vcolp)
if (curwin->w_cursor.lnum != Insstart.lnum if (curwin->w_cursor.lnum != Insstart.lnum
|| curwin->w_cursor.col >= Insstart.col) || curwin->w_cursor.col >= Insstart.col)
replace_do_bs(-1); replace_do_bs(-1);
} else } else {
(void)del_char(FALSE); (void)del_char(false);
}
} }
/// Handle Backspace, delete-word and delete-line in Insert mode. /// Handle Backspace, delete-word and delete-line in Insert mode.
@@ -7782,16 +7787,16 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
else { else {
const bool l_enc_utf8 = enc_utf8; const bool l_enc_utf8 = enc_utf8;
const int l_p_deco = p_deco; const int l_p_deco = p_deco;
if (l_enc_utf8 && l_p_deco) if (l_enc_utf8 && l_p_deco) {
(void)utfc_ptr2char(get_cursor_pos_ptr(), cpc); (void)utfc_ptr2char(get_cursor_pos_ptr(), cpc);
(void)del_char(FALSE); }
/* (void)del_char(false);
* If there are combining characters and 'delcombine' is set // If there are combining characters and 'delcombine' is set
* move the cursor back. Don't back up before the base // move the cursor back. Don't back up before the base
* character. // character.
*/ if (l_enc_utf8 && l_p_deco && cpc[0] != NUL) {
if (l_enc_utf8 && l_p_deco && cpc[0] != NUL)
inc_cursor(); inc_cursor();
}
if (revins_chars) { if (revins_chars) {
revins_chars--; revins_chars--;
revins_legal++; revins_legal++;

View File

@@ -1081,7 +1081,7 @@ int fkmap(int c)
if (gchar_cursor() == _LAM) { if (gchar_cursor() == _LAM) {
chg_l_toXor_X(); chg_l_toXor_X();
del_char(FALSE); del_char(false);
AppendCharToRedobuff(K_BS); AppendCharToRedobuff(K_BS);
if (!p_ri) { if (!p_ri) {

View File

@@ -1555,14 +1555,12 @@ void ins_str(char_u *s)
curwin->w_cursor.col += newlen; curwin->w_cursor.col += newlen;
} }
/* // Delete one character under the cursor.
* Delete one character under the cursor. // If "fixpos" is true, don't leave the cursor on the NUL after the line.
* If "fixpos" is TRUE, don't leave the cursor on the NUL after the line. // Caller must have prepared for undo.
* Caller must have prepared for undo. //
* // return FAIL for failure, OK otherwise
* return FAIL for failure, OK otherwise int del_char(bool fixpos)
*/
int del_char(int fixpos)
{ {
if (has_mbyte) { if (has_mbyte) {
/* Make sure the cursor is at the start of a character. */ /* Make sure the cursor is at the start of a character. */

View File

@@ -1958,7 +1958,7 @@ int swapchar(int op_type, pos_T *pos)
/* Special handling of German sharp s: change to "SS". */ /* Special handling of German sharp s: change to "SS". */
curwin->w_cursor = *pos; curwin->w_cursor = *pos;
del_char(FALSE); del_char(false);
ins_char('S'); ins_char('S');
ins_char('S'); ins_char('S');
curwin->w_cursor = sp; curwin->w_cursor = sp;