diff options
author | watiko <service@mail.watiko.net> | 2016-02-07 09:58:52 +0900 |
---|---|---|
committer | watiko <service@mail.watiko.net> | 2016-02-11 15:13:30 +0900 |
commit | 4a0e10fb2c584ae5cbd95041373944663fa8755d (patch) | |
tree | 9fc10619cff40528c198f7baf35473f86f142205 /src/nvim/ops.c | |
parent | 84281bf675f77f417d26a68611406ef43fd82f7f (diff) | |
download | rneovim-4a0e10fb2c584ae5cbd95041373944663fa8755d.tar.gz rneovim-4a0e10fb2c584ae5cbd95041373944663fa8755d.tar.bz2 rneovim-4a0e10fb2c584ae5cbd95041373944663fa8755d.zip |
vim-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)
https://github.com/vim/vim/commit/d009e8682686a56f7565e6e093a42cd0596e121f
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r-- | src/nvim/ops.c | 54 |
1 files changed, 15 insertions, 39 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 7614e6365a..fd3424509f 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1555,55 +1555,31 @@ int op_delete(oparg_T *oap) if (gchar_cursor() != NUL) curwin->w_cursor.coladd = 0; } - 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 - ); - } - } else { /* delete characters between lines */ + + (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(oap->line_count - 2, FALSE); + truncate_line(true); // delete from cursor to end of line - if (delete_last_line) - oap->end.lnum = curbuf->b_ml.ml_line_count; + curpos = curwin->w_cursor; // remember curwin->w_cursor + curwin->w_cursor.lnum++; + del_lines(oap->line_count - 2, false); + // 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) { - 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); } } |