aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorwatiko <service@mail.watiko.net>2016-02-07 09:58:52 +0900
committerwatiko <service@mail.watiko.net>2016-02-11 15:13:30 +0900
commit4a0e10fb2c584ae5cbd95041373944663fa8755d (patch)
tree9fc10619cff40528c198f7baf35473f86f142205 /src
parent84281bf675f77f417d26a68611406ef43fd82f7f (diff)
downloadrneovim-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')
-rw-r--r--src/nvim/normal.c31
-rw-r--r--src/nvim/ops.c54
-rw-r--r--src/nvim/version.c2
3 files changed, 30 insertions, 57 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 049d650f86..233be6d32d 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -1538,9 +1538,11 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
curbuf->b_visual_mode_eval = VIsual_mode;
}
- /* In Select mode, a linewise selection is operated upon like a
- * characterwise selection. */
- if (VIsual_select && VIsual_mode == 'V') {
+ // In Select mode, a linewise selection is operated upon like a
+ // characterwise selection.
+ // Special case: gH<Del> deletes the last line.
+ if (VIsual_select && VIsual_mode == 'V'
+ && cap->oap->op_type != OP_DELETE) {
if (lt(VIsual, curwin->w_cursor)) {
VIsual.col = 0;
curwin->w_cursor.col =
@@ -1676,20 +1678,15 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
&& (include_line_break || !virtual_op)
) {
oap->inclusive = false;
- /* Try to include the newline, unless it's an operator
- * that works on lines only. */
- if (*p_sel != 'o' && !op_on_lines(oap->op_type)) {
- if (oap->end.lnum < curbuf->b_ml.ml_line_count) {
- ++oap->end.lnum;
- oap->end.col = 0;
- oap->end.coladd = 0;
- ++oap->line_count;
- } else {
- /* Cannot move below the last line, make the op
- * inclusive to tell the operation to include the
- * line break. */
- oap->inclusive = true;
- }
+ // Try to include the newline, unless it's an operator
+ // that works on lines only.
+ if (*p_sel != 'o'
+ && !op_on_lines(oap->op_type)
+ && oap->end.lnum < curbuf->b_ml.ml_line_count) {
+ oap->end.lnum++;
+ oap->end.col = 0;
+ oap->end.coladd = 0;
+ oap->line_count++;
}
}
}
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);
}
}
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 487f3fc27b..90bf3c7572 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -554,7 +554,7 @@ static int included_patches[] = {
737,
736,
// 735 NA
- // 734,
+ 734,
// 733,
732,
// 731 NA