]> granicus.if.org Git - vim/commitdiff
patch 8.2.4215: illegal memory access when copying lines in Visual mode v8.2.4215
authorBram Moolenaar <Bram@vim.org>
Tue, 25 Jan 2022 13:52:53 +0000 (13:52 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 25 Jan 2022 13:52:53 +0000 (13:52 +0000)
Problem:    Illegal memory access when copying lines in Visual mode.
Solution:   Adjust the Visual position after copying lines.

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

index 95209985e190af2ae1586c7055fefa0fac623a81..f5d93e664531ef5ff548ea1d459db002bd0ba838 100644 (file)
@@ -866,6 +866,8 @@ ex_copy(linenr_T line1, linenr_T line2, linenr_T n)
     }
 
     appended_lines_mark(n, count);
+    if (VIsual_active)
+       check_pos(curbuf, &VIsual);
 
     msgmore((long)count);
 }
index 72f5388b934dfd1b013a883cec1eacfb09105597..9b322fd211b385ec147c9867d09de4ff1552f6aa 100644 (file)
@@ -1328,5 +1328,16 @@ func Test_visual_exchange_windows()
   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
index 5d7eccb19109b0b2222e42894e37b117479da698..ddc34d864be9863bf0bb4d4d15c07e693398c9ee 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4215,
 /**/
     4214,
 /**/