]> granicus.if.org Git - vim/commitdiff
patch 8.2.3072: "zy" does not work well when "virtualedit' is "block" v8.2.3072
authorBram Moolenaar <Bram@vim.org>
Mon, 28 Jun 2021 19:54:27 +0000 (21:54 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 28 Jun 2021 19:54:27 +0000 (21:54 +0200)
Problem:    The "zy" command does not work well when 'virtualedit' is set to
            "block". (Johann Höchtl)
Solution:   Make endspaces zero. (Christian Brabandt, closes #8468,
            closes #8448)

src/register.c
src/testdir/test_visual.vim
src/version.c

index 4774e2a99589ad1939465fd5cf43b93c8e8be27e..93ee7aad976343e741504d69019c52ed2b46d1b7 100644 (file)
@@ -1455,6 +1455,8 @@ yank_copy_line(struct block_def *bd, long y_idx, int exclude_trailing_space)
 {
     char_u     *pnew;
 
+    if (exclude_trailing_space)
+       bd->endspaces = 0;
     if ((pnew = alloc(bd->startspaces + bd->endspaces + bd->textlen + 1))
                                                                      == NULL)
        return FAIL;
@@ -2747,7 +2749,7 @@ write_reg_contents_lst(
                &yank_type) == FAIL)
        return;
 
-    str_to_reg(y_current, yank_type, (char_u *) strings, -1, block_len, TRUE);
+    str_to_reg(y_current, yank_type, (char_u *)strings, -1, block_len, TRUE);
 
     finish_write_reg(name, old_y_previous, old_y_current);
 }
index fb2675082937e0b98210d92dcaaae2fb18ce4333..fbd3ca4fcde6b36eb3429210da38c3c7849e5ab6 100644 (file)
@@ -1,6 +1,7 @@
 " Tests for various Visual modes.
 
 source shared.vim
+source check.vim
 
 func Test_block_shift_multibyte()
   " Uses double-wide character.
@@ -1225,5 +1226,24 @@ func Test_visual_put_in_block_using_zy_and_zp()
   bwipe!
 endfunc
 
+func Test_visual_put_blockedit_zy_and_zp()
+  new
+
+  call setline(1, ['aa', 'bbbbb', 'ccc', '', 'XX', 'GGHHJ', 'RTZU'])
+  exe "normal! gg0\<c-v>2j$zy"
+  norm! 5gg0zP
+  call assert_equal(['aa', 'bbbbb', 'ccc', '', 'aaXX', 'bbbbbGGHHJ', 'cccRTZU'], getline(1, 7))
+  "
+  " now with blockmode editing
+  sil %d
+  :set ve=block
+  call setline(1, ['aa', 'bbbbb', 'ccc', '', 'XX', 'GGHHJ', 'RTZU'])
+  exe "normal! gg0\<c-v>2j$zy"
+  norm! 5gg0zP
+  call assert_equal(['aa', 'bbbbb', 'ccc', '', 'aaXX', 'bbbbbGGHHJ', 'cccRTZU'], getline(1, 7))
+  set ve&vim
+  bw!
+endfunc
+
 
 " vim: shiftwidth=2 sts=2 expandtab
index dd74d2dbeefc3a7adf5f924d97e3e552fdc24c64..f33d7dd6be002dfd353da86391b26af50c4a45fd 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3072,
 /**/
     3071,
 /**/