Blob Blame History Raw
diff -up vim80/src/ex_cmds.c.cve0361 vim80/src/ex_cmds.c
--- vim80/src/ex_cmds.c.cve0361	2022-02-08 12:20:51.277666290 +0100
+++ vim80/src/ex_cmds.c	2022-02-08 12:20:51.280666209 +0100
@@ -983,6 +983,8 @@ ex_copy(linenr_T line1, linenr_T line2,
     }
 
     appended_lines_mark(n, count);
+    if (VIsual_active)
+	check_pos(curbuf, &VIsual);
 
     msgmore((long)count);
 }
diff -up vim80/src/testdir/test_visual.vim.cve0361 vim80/src/testdir/test_visual.vim
--- vim80/src/testdir/test_visual.vim.cve0361	2022-02-08 12:20:51.280666209 +0100
+++ vim80/src/testdir/test_visual.vim	2022-02-08 12:21:44.530356814 +0100
@@ -263,3 +263,17 @@ func Test_visual_block_append_invalid_ch
   call assert_equal(['	-   let xxx', 'xxxxx   -ˆ', 'xxxxxxxx-xxx'], getline(1, 3))
   bwipe!
 endfunc
+
+" this was leaving the end of the Visual area beyond the end of a line
+func Test_visual_ex_copy_line()
+  new
+  call setline(1, ["aaa", "bbbbbbbbbxbb"])
+  /x
+  exe "normal ggvjfxO"
+  t0
+  normal gNU
+  bwipe!
+endfunc
+
+
+" vim: shiftwidth=2 sts=2 expandtab