summaryrefslogtreecommitdiff
path: root/src/ops.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2011-07-15 17:51:34 +0200
committerBram Moolenaar <Bram@vim.org>2011-07-15 17:51:34 +0200
commit44286ca3c40cd744d1a007443bbb3624f9c5c53c (patch)
tree650b3456d05024a91f558195106be5ca77f835ce /src/ops.c
parent3d64a3176c9ffe249ad4b5403a18f8364e707813 (diff)
downloadvim-git-44286ca3c40cd744d1a007443bbb3624f9c5c53c.tar.gz
updated for version 7.3.251v7.3.251
Problem: "gH<Del>" deletes the current line, except when it's the last line. Solution: Set the "include" flag to indicate the last line is to be deleted.
Diffstat (limited to 'src/ops.c')
-rw-r--r--src/ops.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/src/ops.c b/src/ops.c
index 8c235220e..bdc53de33 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -1650,7 +1650,9 @@ op_delete(oap)
&& oap->line_count > 1
&& oap->op_type == OP_DELETE)
{
- ptr = ml_get(oap->end.lnum) + oap->end.col + oap->inclusive;
+ ptr = ml_get(oap->end.lnum) + oap->end.col;
+ if (*ptr != NUL)
+ ptr += oap->inclusive;
ptr = skipwhite(ptr);
if (*ptr == NUL && inindent(0))
oap->motion_type = MLINE;
@@ -1920,11 +1922,20 @@ op_delete(oap)
curwin->w_cursor.coladd = 0;
}
#endif
- (void)del_bytes((long)n, !virtual_op, oap->op_type == OP_DELETE
+ if (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
#ifdef FEAT_VISUAL
&& !oap->is_VIsual
#endif
);
+ }
}
else /* delete characters between lines */
{
@@ -1941,17 +1952,29 @@ op_delete(oap)
++curwin->w_cursor.lnum;
del_lines((long)(oap->line_count - 2), FALSE);
- /* delete from start of line until op_end */
- curwin->w_cursor.col = 0;
- (void)del_bytes((long)(oap->end.col + 1 - !oap->inclusive),
- !virtual_op, oap->op_type == OP_DELETE
+ n = (oap->end.col + 1 - !oap->inclusive);
+ if (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);
+ curwin->w_cursor = curpos; /* restore curwin->w_cursor */
+ if (curwin->w_cursor.lnum > 1)
+ --curwin->w_cursor.lnum;
+ }
+ 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
#ifdef FEAT_VISUAL
&& !oap->is_VIsual
#endif
);
- curwin->w_cursor = curpos; /* restore curwin->w_cursor */
-
- (void)do_join(2, FALSE, FALSE);
+ 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);
}
}