From abf42b7ec6b408d4b4ce8c66b6a8a77c638d3c75 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 14 Feb 2022 13:08:00 +0000 Subject: [PATCH 1/7] test(old): cherry-pick test_visual changes from v8.2.0369 https://github.com/vim/vim/commit/1671f4488105ee12a6a8558ae351436c26ab55fc Omit Test_AAA_start_visual_mode_with_count comment change as it hasn't been ported yet. --- src/nvim/testdir/test_visual.vim | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 099a90643f..2fc7fd0e9c 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -132,11 +132,16 @@ func Test_blockwise_visual_o_O() exe "norm! gvO\rb" exe "norm! gvo\rc" exe "norm! gvO\rd" + set selection=exclusive + exe "norm! gvOo\re" + call assert_equal('...a be.', getline(4)) + exe "norm! gvOO\rf" + set selection& call assert_equal(['..........', \ '...c d..', \ '... ..', - \ '...a b..', + \ '...a bf.', \ '..........'], getline(1, '$')) enew! @@ -658,6 +663,16 @@ func Test_characterwise_select_mode() exe "normal Gkgh\\\" call assert_equal(['', 'a', ''], getline(1, '$')) + " CTRL-H in select mode behaves like 'x' + call setline(1, 'abcdef') + exe "normal! gggh\\\\" + call assert_equal('ef', getline(1)) + + " CTRL-O in select mode switches to visual mode for one command + call setline(1, 'abcdef') + exe "normal! gggh\3lm" + call assert_equal('mef', getline(1)) + sunmap End> sunmap Down> sunmap Del> @@ -757,8 +772,7 @@ endfunc func Test_visual_block_mode() new call append(0, '') - call setline(1, ['abcdefghijklm', 'abcdefghijklm', 'abcdefghijklm', - \ 'abcdefghijklm', 'abcdefghijklm']) + call setline(1, repeat(['abcdefghijklm'], 5)) call cursor(1, 1) " Test shift-right of a block @@ -777,6 +791,16 @@ func Test_visual_block_mode() \ 'axyzqqqqefgmnoklm', \ 'abcdqqqqijklm'], getline(1, 5)) + " Test 'C' to change till the end of the line + call cursor(3, 4) + exe "normal! \j3lCooo" + call assert_equal(['axyooo', 'axyooo'], getline(3, 4)) + + " Test 'D' to delete till the end of the line + call cursor(3, 3) + exe "normal! \j2lD" + call assert_equal(['ax', 'ax'], getline(3, 4)) + " Test from ':help v_b_I_example' %d _ setlocal tabstop=8 shiftwidth=4 From b7e6c1b525613bd0ece6fde8c1bcbc52fdc9372f Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 14 Feb 2022 13:20:26 +0000 Subject: [PATCH 2/7] test(old): cherry-pick test_visual changes from v8.2.2901 https://github.com/vim/vim/commit/3e72dcad8b752a42b6eaf71213e3f5d534175256 --- src/nvim/testdir/test_visual.vim | 101 +++++++++++++++++++++++++++---- 1 file changed, 89 insertions(+), 12 deletions(-) diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 2fc7fd0e9c..2c79ed25f5 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -59,7 +59,7 @@ endfunc " Test for visual block shift and tab characters. func Test_block_shift_tab() - enew! + new call append(0, repeat(['one two three'], 5)) call cursor(1,1) exe "normal i\u" @@ -68,7 +68,7 @@ func Test_block_shift_tab() call assert_equal('on1 two three', getline(2)) call assert_equal('on1 two three', getline(5)) - enew! + %d _ call append(0, repeat(['abcdefghijklmnopqrstuvwxyz'], 5)) call cursor(1,1) exe "normal \4jI \j<<11|D" @@ -93,12 +93,26 @@ func Test_block_shift_tab() call assert_equal(" abc\\defghijklmnopqrstuvwxyz", getline(4)) call assert_equal(" abc\ defghijklmnopqrstuvwxyz", getline(5)) - enew! + " Test for block shift with space characters at the beginning and with + " 'noexpandtab' and 'expandtab' + %d _ + call setline(1, [" 1", " 2", " 3"]) + setlocal shiftwidth=2 noexpandtab + exe "normal gg\3j>" + call assert_equal(["\t1", "\t2", "\t3"], getline(1, '$')) + %d _ + call setline(1, [" 1", " 2", " 3"]) + setlocal shiftwidth=2 expandtab + exe "normal gg\3j>" + call assert_equal([" 1", " 2", " 3"], getline(1, '$')) + setlocal shiftwidth& + + bw! endfunc " Tests Blockwise Visual when there are TABs before the text. func Test_blockwise_visual() - enew! + new call append(0, ['123456', \ '234567', \ '345678', @@ -120,12 +134,12 @@ func Test_blockwise_visual() \ "\t\tsomext", \ "\t\ttesext"], getline(1, 7)) - enew! + bw! endfunc " Test swapping corners in blockwise visual mode with o and O func Test_blockwise_visual_o_O() - enew! + new exe "norm! 10i.\Y4P3lj\4l2jr " exe "norm! gvO\ra" @@ -144,7 +158,7 @@ func Test_blockwise_visual_o_O() \ '...a bf.', \ '..........'], getline(1, '$')) - enew! + bw! endfun " Test Virtual replace mode. @@ -273,7 +287,6 @@ func Test_visual_mode_reset() " thus preventing the problem: exe "normal! GV:call TriggerTheProblem()\" call assert_equal("Everything's fine.", g:msg) - endfunc func Test_Visual_word_textobject() @@ -440,15 +453,13 @@ endfunc " Test for 'p'ut in visual block mode func Test_visual_block_put() - enew - + new call append(0, ['One', 'Two', 'Three']) normal gg yank call feedkeys("jl\ljp", 'xt') call assert_equal(['One', 'T', 'Tee', 'One', ''], getline(1, '$')) - - enew! + bw! endfunc func Test_visual_put_in_block() @@ -628,6 +639,12 @@ func Test_characterwise_visual_mode() normal Gkvj$d call assert_equal(['', 'a', ''], getline(1, '$')) + " characterwise visual mode: replace a single character line and the eol + %d _ + call setline(1, "a") + normal v$rx + call assert_equal(['x'], getline(1, '$')) + bwipe! endfunc @@ -801,6 +818,66 @@ func Test_visual_block_mode() exe "normal! \j2lD" call assert_equal(['ax', 'ax'], getline(3, 4)) + " Test block insert with a short line that ends before the block + %d _ + call setline(1, [" one", "a", " two"]) + exe "normal gg\2jIx" + call assert_equal([" xone", "a", " xtwo"], getline(1, '$')) + + " Test block append at EOL with '$' and without '$' + %d _ + call setline(1, ["one", "a", "two"]) + exe "normal gg$\2jAx" + call assert_equal(["onex", "ax", "twox"], getline(1, '$')) + %d _ + call setline(1, ["one", "a", "two"]) + exe "normal gg3l\2jAx" + call assert_equal(["onex", "a x", "twox"], getline(1, '$')) + + " Test block replace with an empty line in the middle and use $ to jump to + " the end of the line. + %d _ + call setline(1, ['one', '', 'two']) + exe "normal gg$\2jrx" + call assert_equal(["onx", "", "twx"], getline(1, '$')) + + " Test block replace with an empty line in the middle and move cursor to the + " end of the line + %d _ + call setline(1, ['one', '', 'two']) + exe "normal gg2l\2jrx" + call assert_equal(["onx", "", "twx"], getline(1, '$')) + + " Replace odd number of characters with a multibyte character + %d _ + call setline(1, ['abcd', 'efgh']) + exe "normal ggl\2ljr\u1100" + call assert_equal(["a\u1100 ", "e\u1100 "], getline(1, '$')) + + " During visual block append, if the cursor moved outside of the selected + " range, then the edit should not be applied to the block. + %d _ + call setline(1, ['aaa', 'bbb', 'ccc']) + exe "normal 2G\jAx\" + call assert_equal(['aaa', 'bxbb', 'ccc'], getline(1, '$')) + + " During visual block append, if the cursor is moved before the start of the + " block, then the new text should be appended there. + %d _ + call setline(1, ['aaa', 'bbb', 'ccc']) + exe "normal $\2jA\x" + " BUG: Instead of adding x as the third character in all the three lines, + " 'a' is added in the second and third lines at the end. This bug is not + " reproducible if this operation is performed manually. + "call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$')) + call assert_equal(['aaxa', 'bbba', 'ccca'], getline(1, '$')) + + " Change a characterwise motion to a blockwise motion using CTRL-V + %d _ + call setline(1, ['123', '456', '789']) + exe "normal ld\j" + call assert_equal(['13', '46', '789'], getline(1, '$')) + " Test from ':help v_b_I_example' %d _ setlocal tabstop=8 shiftwidth=4 From d5d51308c0e531f6c2dec6b5570b3ffe04ab6b45 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 14 Feb 2022 13:26:42 +0000 Subject: [PATCH 3/7] test(old): cherry-pick test_visual changes from v8.2.2945 https://github.com/vim/vim/commit/59b262362f26b3aaea1eeb0078adc33eed59863e --- src/nvim/testdir/test_visual.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 2c79ed25f5..d05035b4e9 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -871,6 +871,10 @@ func Test_visual_block_mode() " reproducible if this operation is performed manually. "call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$')) call assert_equal(['aaxa', 'bbba', 'ccca'], getline(1, '$')) + " Repeat the previous test but use 'l' to move the cursor instead of '$' + call setline(1, ['aaa', 'bbb', 'ccc']) + exe "normal! gg2l\2jA\x" + call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$')) " Change a characterwise motion to a blockwise motion using CTRL-V %d _ From f8b75e582215be5ed07aebb02cdbe69de8cad393 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 14 Feb 2022 01:58:47 +0000 Subject: [PATCH 4/7] vim-patch:8.2.3073: when cursor is move for block append wrong text is inserted Problem: When cursor is move for block append wrong text is inserted. Solution: Calculate an offset. (Christian Brabandt, closes vim/vim#8433, closes vim/vim#8288) https://github.com/vim/vim/commit/4067bd3604215b48e4b4201e28f9e401b08418e4 --- src/nvim/ops.c | 56 +++++++++++++++++++---------- src/nvim/testdir/test_blockedit.vim | 48 +++++++++++++++++++++++++ src/nvim/testdir/test_visual.vim | 6 +--- 3 files changed, 87 insertions(+), 23 deletions(-) diff --git a/src/nvim/ops.c b/src/nvim/ops.c index f999b68236..68ce9824c7 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -580,6 +580,9 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def spaces -= off; count -= off; } + if (spaces < 0) { // can happen when the cursor was moved + spaces = 0; + } assert(count >= 0); newp = (char_u *)xmalloc(STRLEN(oldp) + s_len + (size_t)count + 1); @@ -2278,6 +2281,7 @@ void op_insert(oparg_T *oap, long count1) } t1 = oap->start; + const pos_T start_insert = curwin->w_cursor; (void)edit(NUL, false, (linenr_T)count1); // When a tab was inserted, and the characters in front of the tab @@ -2315,26 +2319,30 @@ void op_insert(oparg_T *oap, long count1) if (oap->start.lnum == curbuf->b_op_start_orig.lnum && !bd.is_MAX && !did_indent) { - if (oap->op_type == OP_INSERT - && oap->start.col + oap->start.coladd - != curbuf->b_op_start_orig.col + curbuf->b_op_start_orig.coladd) { - int t = getviscol2(curbuf->b_op_start_orig.col, - curbuf->b_op_start_orig.coladd); - oap->start.col = curbuf->b_op_start_orig.col; - pre_textlen -= t - oap->start_vcol; - oap->start_vcol = t; - } else if (oap->op_type == OP_APPEND - && oap->end.col + oap->end.coladd - >= curbuf->b_op_start_orig.col - + curbuf->b_op_start_orig.coladd) { - int t = getviscol2(curbuf->b_op_start_orig.col, - curbuf->b_op_start_orig.coladd); - oap->start.col = curbuf->b_op_start_orig.col; + const int t = getviscol2(curbuf->b_op_start_orig.col, curbuf->b_op_start_orig.coladd); + + if (!bd.is_MAX) { + if (oap->op_type == OP_INSERT + && oap->start.col + oap->start.coladd + != curbuf->b_op_start_orig.col + curbuf->b_op_start_orig.coladd) { + oap->start.col = curbuf->b_op_start_orig.col; + pre_textlen -= t - oap->start_vcol; + oap->start_vcol = t; + } else if (oap->op_type == OP_APPEND + && oap->end.col + oap->end.coladd + >= curbuf->b_op_start_orig.col + + curbuf->b_op_start_orig.coladd) { + oap->start.col = curbuf->b_op_start_orig.col; + // reset pre_textlen to the value of OP_INSERT + pre_textlen += bd.textlen; + pre_textlen -= t - oap->start_vcol; + oap->start_vcol = t; + oap->op_type = OP_INSERT; + } + } else if (bd.is_MAX && oap->op_type == OP_APPEND) { // reset pre_textlen to the value of OP_INSERT pre_textlen += bd.textlen; pre_textlen -= t - oap->start_vcol; - oap->start_vcol = t; - oap->op_type = OP_INSERT; } } @@ -2376,15 +2384,27 @@ void op_insert(oparg_T *oap, long count1) firstline = ml_get(oap->start.lnum); const size_t len = STRLEN(firstline); colnr_T add = bd.textcol; + colnr_T offset = 0; // offset when cursor was moved in insert mode if (oap->op_type == OP_APPEND) { add += bd.textlen; + // account for pressing cursor in insert mode when '$' was used + if (bd.is_MAX && start_insert.lnum == Insstart.lnum && start_insert.col > Insstart.col) { + offset = start_insert.col - Insstart.col; + add -= offset; + if (oap->end_vcol > offset) { + oap->end_vcol -= offset + 1; + } else { + // moved outside of the visual block, what to do? + return; + } + } } if ((size_t)add > len) { firstline += len; // short line, point to the NUL } else { firstline += add; } - ins_len = (long)STRLEN(firstline) - pre_textlen; + ins_len = (long)STRLEN(firstline) - pre_textlen - offset; if (pre_textlen >= 0 && ins_len > 0) { ins_text = vim_strnsave(firstline, (size_t)ins_len); // block handled here diff --git a/src/nvim/testdir/test_blockedit.vim b/src/nvim/testdir/test_blockedit.vim index 38978ef689..7b56b1554f 100644 --- a/src/nvim/testdir/test_blockedit.vim +++ b/src/nvim/testdir/test_blockedit.vim @@ -81,4 +81,52 @@ func Test_blockinsert_delete() bwipe! endfunc +func Test_blockappend_eol_cursor() + new + " Test 1 Move 1 char left + call setline(1, ['aaa', 'bbb', 'ccc']) + exe "norm! gg$\2jA\x\" + call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$')) + " Test 2 Move 2 chars left + sil %d + call setline(1, ['aaa', 'bbb', 'ccc']) + exe "norm! gg$\2jA\\x\" + call assert_equal(['axaa', 'bxbb', 'cxcc'], getline(1, '$')) + " Test 3 Move 3 chars left (outside of the visual selection) + sil %d + call setline(1, ['aaa', 'bbb', 'ccc']) + exe "norm! ggl$\2jA\\\x\" + call assert_equal(['xaaa', 'bbb', 'ccc'], getline(1, '$')) + bw! +endfunc + +func Test_blockappend_eol_cursor2() + new + " Test 1 Move 1 char left + call setline(1, ['aaaaa', 'bbb', 'ccccc']) + exe "norm! gg\$2jA\x\" + call assert_equal(['aaaaxa', 'bbbx', 'ccccxc'], getline(1, '$')) + " Test 2 Move 2 chars left + sil %d + call setline(1, ['aaaaa', 'bbb', 'ccccc']) + exe "norm! gg\$2jA\\x\" + call assert_equal(['aaaxaa', 'bbbx', 'cccxcc'], getline(1, '$')) + " Test 3 Move 3 chars left (to the beginning of the visual selection) + sil %d + call setline(1, ['aaaaa', 'bbb', 'ccccc']) + exe "norm! gg\$2jA\\\x\" + call assert_equal(['aaxaaa', 'bbxb', 'ccxccc'], getline(1, '$')) + " Test 4 Move 3 chars left (outside of the visual selection) + sil %d + call setline(1, ['aaaaa', 'bbb', 'ccccc']) + exe "norm! ggl\$2jA\\\x\" + call assert_equal(['aaxaaa', 'bbxb', 'ccxccc'], getline(1, '$')) + " Test 5 Move 4 chars left (outside of the visual selection) + sil %d + call setline(1, ['aaaaa', 'bbb', 'ccccc']) + exe "norm! ggl\$2jA\\\\x\" + call assert_equal(['axaaaa', 'bxbb', 'cxcccc'], getline(1, '$')) + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index d05035b4e9..f95801cab5 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -866,11 +866,7 @@ func Test_visual_block_mode() %d _ call setline(1, ['aaa', 'bbb', 'ccc']) exe "normal $\2jA\x" - " BUG: Instead of adding x as the third character in all the three lines, - " 'a' is added in the second and third lines at the end. This bug is not - " reproducible if this operation is performed manually. - "call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$')) - call assert_equal(['aaxa', 'bbba', 'ccca'], getline(1, '$')) + call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$')) " Repeat the previous test but use 'l' to move the cursor instead of '$' call setline(1, ['aaa', 'bbb', 'ccc']) exe "normal! gg2l\2jA\x" From e662d86e8d3198ea77e1a6d0b9be7c09255de520 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Thu, 3 Feb 2022 01:10:33 +0000 Subject: [PATCH 5/7] vim-patch:8.2.4120: block insert goes over the end of the line Problem: Block insert goes over the end of the line. Solution: Handle invalid byte better. Fix inserting the wrong text. https://github.com/vim/vim/commit/9f8c304c8a390ade133bac29963dc8e56ab14cbc --- src/nvim/ops.c | 38 ++++++++++++++++++++------------ src/nvim/testdir/test_visual.vim | 9 ++++++++ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 68ce9824c7..e712aa18b3 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -573,19 +573,24 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def // Avoid starting halfway through a multi-byte character. if (b_insert) { off = utf_head_off(oldp, oldp + offset + spaces); + spaces -= off; + count -= off; } else { - off = mb_off_next(oldp, oldp + offset); - offset += off; + // spaces fill the gap, the character that's at the edge moves + // right + off = utf_head_off(oldp, oldp + offset); + offset -= off; } - spaces -= off; - count -= off; } if (spaces < 0) { // can happen when the cursor was moved spaces = 0; } assert(count >= 0); - newp = (char_u *)xmalloc(STRLEN(oldp) + s_len + (size_t)count + 1); + // Make sure the allocated size matches what is actually copied below. + newp = xmalloc(STRLEN(oldp) + (size_t)spaces + s_len + + (spaces > 0 && !bdp->is_short ? (size_t)p_ts - (size_t)spaces : 0) + + (size_t)count + 1); // copy up to shifted part memmove(newp, oldp, (size_t)offset); @@ -600,14 +605,19 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def offset += (int)s_len; int skipped = 0; - if (spaces && !bdp->is_short) { - // insert post-padding - memset(newp + offset + spaces, ' ', (size_t)(p_ts - spaces)); - // We're splitting a TAB, don't copy it. - oldp++; - // We allowed for that TAB, remember this now - count++; - skipped = 1; + if (spaces > 0 && !bdp->is_short) { + if (*oldp == TAB) { + // insert post-padding + memset(newp + offset + spaces, ' ', (size_t)(p_ts - spaces)); + // We're splitting a TAB, don't copy it. + oldp++; + // We allowed for that TAB, remember this now + count++; + skipped = 1; + } else { + // Not a TAB, no extra spaces + count = spaces; + } } if (spaces > 0) { @@ -2329,7 +2339,7 @@ void op_insert(oparg_T *oap, long count1) pre_textlen -= t - oap->start_vcol; oap->start_vcol = t; } else if (oap->op_type == OP_APPEND - && oap->end.col + oap->end.coladd + && oap->start.col + oap->start.coladd >= curbuf->b_op_start_orig.col + curbuf->b_op_start_orig.coladd) { oap->start.col = curbuf->b_op_start_orig.col; diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index f95801cab5..a2c93bd573 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -1242,6 +1242,15 @@ func Test_visual_block_ctrl_w_f() au! BufNew endfunc +func Test_visual_block_append_invalid_char() + " this was going over the end of the line + new + call setline(1, [' let xxx', 'xxxxxˆ', 'xxxxxxxxxxx']) + exe "normal 0\jjA-\" + call assert_equal([' - let xxx', 'xxxxx -ˆ', 'xxxxxxxx-xxx'], getline(1, 3)) + bwipe! +endfunc + func Test_visual_reselect_with_count() " this was causing an illegal memory access let lines =<< trim END From afbed8cb75af714a636128c4ad7fb4be6edf7727 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Thu, 3 Feb 2022 01:22:24 +0000 Subject: [PATCH 6/7] vim-patch:8.2.4151: reading beyond the end of a line Problem: Reading beyond the end of a line. Solution: For block insert only use the offset for correcting the length. https://github.com/vim/vim/commit/57df9e8a9f9ae1aafdde9b86b10ad907627a87dc --- src/nvim/ops.c | 15 ++------------- src/nvim/testdir/test_visual.vim | 9 +++++++++ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/nvim/ops.c b/src/nvim/ops.c index e712aa18b3..c9a99fef84 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -568,19 +568,8 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def } if (spaces > 0) { - int off; - - // Avoid starting halfway through a multi-byte character. - if (b_insert) { - off = utf_head_off(oldp, oldp + offset + spaces); - spaces -= off; - count -= off; - } else { - // spaces fill the gap, the character that's at the edge moves - // right - off = utf_head_off(oldp, oldp + offset); - offset -= off; - } + // avoid copying part of a multi-byte character + offset -= utf_head_off(oldp, oldp + offset); } if (spaces < 0) { // can happen when the cursor was moved spaces = 0; diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index a2c93bd573..edb72c82e3 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -1271,6 +1271,15 @@ func Test_visual_reselect_with_count() call delete('XvisualReselect') endfunc +func Test_visual_block_insert_round_off() + new + " The number of characters are tuned to fill a 4096 byte allocated block, + " so that valgrind reports going over the end. + call setline(1, ['xxxxx', repeat('0', 1350), "\t", repeat('x', 60)]) + exe "normal gg0\GI" .. repeat('0', 1320) .. "\" + bwipe! +endfunc + " this was leaving the end of the Visual area beyond the end of a line func Test_visual_ex_copy_line() new From 2b75ac7aa9cfc6f8b49b4399c02bada45af450d4 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 13 Feb 2022 19:02:06 +0000 Subject: [PATCH 7/7] vim-patch:8.2.4152: block insert with double wide character fails Problem: Block insert with double wide character fails. Solution: Adjust the expected output. https://github.com/vim/vim/commit/fc6ccebea668c49e9e617e0657421b6a8ed9df1e --- src/nvim/testdir/test_utf8.vim | 2 +- test/functional/legacy/utf8_spec.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nvim/testdir/test_utf8.vim b/src/nvim/testdir/test_utf8.vim index 36776d5a64..9b010a5dbc 100644 --- a/src/nvim/testdir/test_utf8.vim +++ b/src/nvim/testdir/test_utf8.vim @@ -8,7 +8,7 @@ func Test_visual_block_insert() new call setline(1, ["aaa", "あああ", "bbb"]) exe ":norm! gg0l\jjIx\" - call assert_equal(['axaa', 'xあああ', 'bxbb'], getline(1, '$')) + call assert_equal(['axaa', ' xあああ', 'bxbb'], getline(1, '$')) bwipeout! endfunc diff --git a/test/functional/legacy/utf8_spec.lua b/test/functional/legacy/utf8_spec.lua index 8b5fc02d11..67a4bec4c5 100644 --- a/test/functional/legacy/utf8_spec.lua +++ b/test/functional/legacy/utf8_spec.lua @@ -28,7 +28,7 @@ describe('utf8', function() expect([[ start: axaa - xあああ + xあああ bxbb]]) end)