]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0126: Internal error when using upper-case mark in getregion() v9.1.0126
authorzeertzjq <zeertzjq@outlook.com>
Thu, 22 Feb 2024 18:48:06 +0000 (19:48 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 22 Feb 2024 18:48:06 +0000 (19:48 +0100)
Problem:  Internal error when passing mark in another buffer to
          getregion().
Solution: Don't allow marks in another buffer (zeertzjq)

closes: #14076

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Internal error when passing mark in another buffer to getregion()

runtime/doc/builtin.txt
src/evalfunc.c
src/testdir/test_visual.vim
src/version.c

index f1256b027c68d6607e3b295999bdba0c78641a42..b117bf84b11a3948aa00af688edab8cd812a64d2 100644 (file)
@@ -1,4 +1,4 @@
-*builtin.txt*  For Vim version 9.1.  Last change: 2024 Feb 21
+*builtin.txt*  For Vim version 9.1.  Last change: 2024 Feb 22
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -4300,6 +4300,8 @@ getregion({pos1}, {pos2}, {type})                 *getregion()*
                  |visual-mode|, an empty list is returned.
                - If {pos1}, {pos2} or {type} is an invalid string, an empty
                  list is returned.
+               - If {pos1} or {pos2} is a mark in different buffer, an empty
+                 list is returned.
 
                Examples: >
                        :xnoremap <CR>
index 071bf7d0f8be46e4a4394be909452a12f56ef5f9..981f8abedf2a323fa5b7a6c2b5ad8b3cb4912cec 100644 (file)
@@ -5508,12 +5508,12 @@ f_getregion(typval_T *argvars, typval_T *rettv)
 
     // NOTE: var2fpos() returns static pointer.
     fp = var2fpos(&argvars[0], TRUE, &fnum, FALSE);
-    if (fp == NULL)
+    if (fp == NULL || (fnum >= 0 && fnum != curbuf->b_fnum))
        return;
     p1 = *fp;
 
     fp = var2fpos(&argvars[1], TRUE, &fnum, FALSE);
-    if (fp == NULL)
+    if (fp == NULL || (fnum >= 0 && fnum != curbuf->b_fnum))
        return;
     p2 = *fp;
 
index 34c572e617c7fbb9eed4d74e4394077793a9772b..8b434238a8da0eb403d4c5d275a046e86df5a469 100644 (file)
@@ -1712,7 +1712,16 @@ func Test_visual_getregion()
   call assert_fails(':echo "."->getregion([],"V")', 'E1174:')
   call assert_fails(':echo "."->getregion("$", {})', 'E1174:')
   call assert_fails(':echo [0, 1, 1, 0]->getregion("$", "v")', 'E1174:')
-
+  " using a mark in another buffer
+  new
+  let newbuf = bufnr()
+  call setline(1, range(10))
+  normal! GmA
+  wincmd p
+  call assert_equal([newbuf, 10, 1, 0], getpos("'A"))
+  call assert_equal([], getregion(".", "'A", 'v'))
+  call assert_equal([], getregion("'A", ".", 'v'))
+  exe newbuf .. 'bwipe!'
 
   bwipe!
   " Selection in starts or ends in the middle of a multibyte character
index f4b2a1eac89c18a9cae97f2003c17e0e0de35d9d..b8e79dd546d05f5f11832aa3f753203c8678c046 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    126,
 /**/
     125,
 /**/