summaryrefslogtreecommitdiff
path: root/src/ops.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ops.c')
-rw-r--r--src/ops.c45
1 files changed, 8 insertions, 37 deletions
diff --git a/src/ops.c b/src/ops.c
index 090d3f891..05b1e1cc2 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -1959,60 +1959,31 @@ op_delete(oap)
curwin->w_cursor.coladd = 0;
}
#endif
- if (oap->op_type == OP_DELETE
- && oap->inclusive
- && oap->end.lnum == curbuf->b_ml.ml_line_count
- && n > (int)STRLEN(ml_get(oap->end.lnum)))
- {
- /* Special case: gH<Del> deletes the last line. */
- del_lines(1L, FALSE);
- }
- else
- {
- (void)del_bytes((long)n, !virtual_op,
- oap->op_type == OP_DELETE && !oap->is_VIsual);
- }
+ (void)del_bytes((long)n, !virtual_op,
+ oap->op_type == OP_DELETE && !oap->is_VIsual);
}
else /* delete characters between lines */
{
pos_T curpos;
- int delete_last_line;
/* save deleted and changed lines for undo */
if (u_save((linenr_T)(curwin->w_cursor.lnum - 1),
(linenr_T)(curwin->w_cursor.lnum + oap->line_count)) == FAIL)
return FAIL;
- delete_last_line = (oap->end.lnum == curbuf->b_ml.ml_line_count);
truncate_line(TRUE); /* delete from cursor to end of line */
curpos = curwin->w_cursor; /* remember curwin->w_cursor */
++curwin->w_cursor.lnum;
del_lines((long)(oap->line_count - 2), FALSE);
- if (delete_last_line)
- oap->end.lnum = curbuf->b_ml.ml_line_count;
-
+ /* delete from start of line until op_end */
n = (oap->end.col + 1 - !oap->inclusive);
- if (oap->inclusive && delete_last_line
- && n > (int)STRLEN(ml_get(oap->end.lnum)))
- {
- /* Special case: gH<Del> deletes the last line. */
- del_lines(1L, FALSE);
- curwin->w_cursor = curpos; /* restore curwin->w_cursor */
- if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
- curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
- }
- else
- {
- /* delete from start of line until op_end */
- curwin->w_cursor.col = 0;
- (void)del_bytes((long)n, !virtual_op,
- oap->op_type == OP_DELETE && !oap->is_VIsual);
- curwin->w_cursor = curpos; /* restore curwin->w_cursor */
- }
- if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)
- (void)do_join(2, FALSE, FALSE, FALSE, FALSE);
+ curwin->w_cursor.col = 0;
+ (void)del_bytes((long)n, !virtual_op,
+ oap->op_type == OP_DELETE && !oap->is_VIsual);
+ curwin->w_cursor = curpos; /* restore curwin->w_cursor */
+ (void)do_join(2, FALSE, FALSE, FALSE, FALSE);
}
}