From d009e8682686a56f7565e6e093a42cd0596e121f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 9 Jun 2015 20:20:03 +0200 Subject: patch 7.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) --- src/ops.c | 45 ++++++++------------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) (limited to 'src/ops.c') 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 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 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); } } -- cgit v1.2.1