summaryrefslogtreecommitdiff
path: root/src/ops.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2015-06-09 20:20:03 +0200
committerBram Moolenaar <Bram@vim.org>2015-06-09 20:20:03 +0200
commitd009e8682686a56f7565e6e093a42cd0596e121f (patch)
tree6c08acb9d982596486b039203dd362691aef1342 /src/ops.c
parentd68f2219b57acb86ddedebdcc1476fee15c9c0c7 (diff)
downloadvim-git-d009e8682686a56f7565e6e093a42cd0596e121f.tar.gz
patch 7.4.734v7.4.734
Problem: ml_get error when using "p" in a Visual selection in the last line. Solution: Change the behavior at the last line. (Yukihiro Nakadaira)
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);
}
}