From 4a0e10fb2c584ae5cbd95041373944663fa8755d Mon Sep 17 00:00:00 2001 From: watiko Date: Sun, 7 Feb 2016 09:58:52 +0900 Subject: 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 --- src/nvim/normal.c | 31 ++++++++++++++----------------- src/nvim/ops.c | 54 +++++++++++++++--------------------------------------- src/nvim/version.c | 2 +- 3 files changed, 30 insertions(+), 57 deletions(-) (limited to 'src') 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 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 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 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 -- cgit From 663e1ed158956a75845642974ab81bba1826ff05 Mon Sep 17 00:00:00 2001 From: watiko Date: Sun, 7 Feb 2016 12:12:07 +0900 Subject: vim-patch:7.4.743 Problem: "p" in Visual mode causes an unexpected line split. Solution: Advance the cursor first. (Yukihiro Nakadaira) https://github.com/vim/vim/commit/c004bc2726eafc7a56d1d9f8398a65a0a7dc8d6c --- src/nvim/ops.c | 26 ++++++++++++++++++-------- src/nvim/version.c | 2 +- 2 files changed, 19 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index fd3424509f..b1adc85e1d 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2664,17 +2664,27 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) if (y_type == MLINE) { if (flags & PUT_LINE_SPLIT) { - /* "p" or "P" in Visual mode: split the lines to put the text in - * between. */ - if (u_save_cursor() == FAIL) + // "p" or "P" in Visual mode: split the lines to put the text in + // between. + if (u_save_cursor() == FAIL) { goto end; - ptr = vim_strsave(get_cursor_pos_ptr()); - ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE); + } + char_u *p = get_cursor_pos_ptr(); + if (dir == FORWARD && *p != NUL) { + mb_ptr_adv(p); + } + ptr = vim_strsave(p); + ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, false); xfree(ptr); - ptr = vim_strnsave(get_cursor_line_ptr(), curwin->w_cursor.col); - ml_replace(curwin->w_cursor.lnum, ptr, FALSE); - ++nr_lines; + oldp = get_cursor_line_ptr(); + p = oldp + curwin->w_cursor.col; + if (dir == FORWARD && *p != NUL) { + mb_ptr_adv(p); + } + ptr = vim_strnsave(oldp, p - oldp); + ml_replace(curwin->w_cursor.lnum, ptr, false); + nr_lines++; dir = FORWARD; } if (flags & PUT_LINE_FORWARD) { diff --git a/src/nvim/version.c b/src/nvim/version.c index 90bf3c7572..4ecfd634a2 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -545,7 +545,7 @@ static int included_patches[] = { 746, 745, // 744 NA - // 743, + 743, 742, 741, 740, -- cgit From 51c3e0aa806820ab24ee481ffc1f67cbef444206 Mon Sep 17 00:00:00 2001 From: watiko Date: Sun, 7 Feb 2016 13:14:43 +0900 Subject: vim-patch:7.4.929 Problem: "gv" after paste selects one character less if 'selection' is "exclusive". Solution: Increment the end position. (Christian Brabandt) https://github.com/vim/vim/commit/d29c6fea94947b3f4b54fbd5a6f832a7d744bf27 --- src/nvim/normal.c | 4 ++++ src/nvim/version.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 233be6d32d..e6c5354941 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -7745,6 +7745,10 @@ static void nv_put(cmdarg_T *cap) if (was_visual) { curbuf->b_visual.vi_start = curbuf->b_op_start; curbuf->b_visual.vi_end = curbuf->b_op_end; + // need to adjust cursor position + if (*p_sel == 'e') { + inc(&curbuf->b_visual.vi_end); + } } /* When all lines were selected and deleted do_put() leaves an empty diff --git a/src/nvim/version.c b/src/nvim/version.c index 4ecfd634a2..bd85b10dd1 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -359,7 +359,7 @@ static int included_patches[] = { // 932, // 931, // 930 NA - // 929, + 929, // 928 NA // 927 NA // 926, -- cgit From bfab33ef7975d8edd467964e59e0d39bf687ed92 Mon Sep 17 00:00:00 2001 From: watiko Date: Sun, 7 Feb 2016 14:15:39 +0900 Subject: vim-patch:7.4.931 (NA) Problem: Test 94 fails on some systems. Solution: Set 'encoding' to utf-8. https://github.com/vim/vim/commit/cfcd1ddd103129b309671cba5cff55e19a9908e4 --- Neovim cannot change encoding after start-up. --- src/nvim/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index bd85b10dd1..80877d61d0 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -357,7 +357,7 @@ static int included_patches[] = { // 934 NA // 933, // 932, - // 931, + // 931 NA // 930 NA 929, // 928 NA -- cgit