summaryrefslogtreecommitdiff
path: root/src/edit.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2007-12-09 19:26:44 +0000
committerBram Moolenaar <Bram@vim.org>2007-12-09 19:26:44 +0000
commitf5dcf7c3b5b59ee107a05a3c6cbb335399a21150 (patch)
treea5a372ca9ac91aaaafe4b2c8935b678fab69eaf7 /src/edit.c
parent6c964835b192d7031dfc87af962154760a5e8ec3 (diff)
downloadvim-git-f5dcf7c3b5b59ee107a05a3c6cbb335399a21150.tar.gz
updated for version 7.1-175v7.1.175
Diffstat (limited to 'src/edit.c')
-rw-r--r--src/edit.c73
1 files changed, 33 insertions, 40 deletions
diff --git a/src/edit.c b/src/edit.c
index f2fe692db..d906d788b 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -8189,6 +8189,29 @@ ins_del()
AppendCharToRedobuff(K_DEL);
}
+static void ins_bs_one __ARGS((colnr_T *vcolp));
+
+/*
+ * Delete one character for ins_bs().
+ */
+ static void
+ins_bs_one(vcolp)
+ colnr_T *vcolp;
+{
+ dec_cursor();
+ getvcol(curwin, &curwin->w_cursor, vcolp, NULL, NULL);
+ if (State & REPLACE_FLAG)
+ {
+ /* Don't delete characters before the insert point when in
+ * Replace mode */
+ if (curwin->w_cursor.lnum != Insstart.lnum
+ || curwin->w_cursor.col >= Insstart.col)
+ replace_do_bs();
+ }
+ else
+ (void)del_char(FALSE);
+}
+
/*
* Handle Backspace, delete-word and delete-line in Insert mode.
* Return TRUE when backspace was actually used.
@@ -8418,9 +8441,7 @@ ins_bs(c, mode, inserted_space_p)
int ts;
colnr_T vcol;
colnr_T want_vcol;
-#if 0
- int extra = 0;
-#endif
+ colnr_T start_vcol;
*inserted_space_p = FALSE;
if (p_sta && in_indent)
@@ -8431,6 +8452,7 @@ ins_bs(c, mode, inserted_space_p)
* 'showbreak' may get in the way, need to get the last column of
* the previous character. */
getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);
+ start_vcol = vcol;
dec_cursor();
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &want_vcol);
inc_cursor();
@@ -8439,30 +8461,7 @@ ins_bs(c, mode, inserted_space_p)
/* delete characters until we are at or before want_vcol */
while (vcol > want_vcol
&& (cc = *(ml_get_cursor() - 1), vim_iswhite(cc)))
- {
- dec_cursor();
- getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);
- if (State & REPLACE_FLAG)
- {
- /* Don't delete characters before the insert point when in
- * Replace mode */
- if (curwin->w_cursor.lnum != Insstart.lnum
- || curwin->w_cursor.col >= Insstart.col)
- {
-#if 0 /* what was this for? It causes problems when sw != ts. */
- if (State == REPLACE && (int)vcol < want_vcol)
- {
- (void)del_char(FALSE);
- extra = 2; /* don't pop too much */
- }
- else
-#endif
- replace_do_bs();
- }
- }
- else
- (void)del_char(FALSE);
- }
+ ins_bs_one(&vcol);
/* insert extra spaces until we are at want_vcol */
while (vcol < want_vcol)
@@ -8479,22 +8478,16 @@ ins_bs(c, mode, inserted_space_p)
#endif
{
ins_str((char_u *)" ");
- if ((State & REPLACE_FLAG) /* && extra <= 1 */)
- {
-#if 0
- if (extra)
- replace_push_off(NUL);
- else
-#endif
- replace_push(NUL);
- }
-#if 0
- if (extra == 2)
- extra = 1;
-#endif
+ if ((State & REPLACE_FLAG))
+ replace_push(NUL);
}
getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);
}
+
+ /* If we are now back where we started delete one character. Can
+ * happen when using 'sts' and 'linebreak'. */
+ if (vcol >= start_vcol)
+ ins_bs_one(&vcol);
}
/*