patch 9.1.0126: Internal error when using upper-case mark in getregion()
Commit:
https://github.com/vim/vim/commit/421b597470c118871c7081de00dd065e0e000b7e
Author: zeertzjq <[email protected]>
Date: Thu Feb 22 19:48:06 2024 +0100
patch 9.1.0126: Internal error when using upper-case mark in getregion()
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 <[email protected]>
Internal error when passing mark in another buffer to getregion()
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index f1256b027..b117bf84b 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -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>
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 071bf7d0f..981f8abed 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -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;
diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim
index 34c572e61..8b434238a 100644
--- a/src/testdir/test_visual.vim
+++ b/src/testdir/test_visual.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index f4b2a1eac..b8e79dd54 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 126,
/**/
125,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/E1rdEIf-00CwdT-Oi%40256bit.org.