mirror of
https://github.com/vim/vim.git
synced 2025-10-01 04:54:07 -04:00
patch 8.2.3950: going beyond the end of the line with /\%V
Problem: Going beyond the end of the line with /\%V. Solution: Check for valid column in getvcol().
This commit is contained in:
@@ -1240,10 +1240,15 @@ getvcol(
|
|||||||
posptr = NULL; // continue until the NUL
|
posptr = NULL; // continue until the NUL
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Special check for an empty line, which can happen on exit, when
|
colnr_T i;
|
||||||
// ml_get_buf() always returns an empty string.
|
|
||||||
if (*ptr == NUL)
|
// In a few cases the position can be beyond the end of the line.
|
||||||
pos->col = 0;
|
for (i = 0; i < pos->col; ++i)
|
||||||
|
if (ptr[i] == NUL)
|
||||||
|
{
|
||||||
|
pos->col = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
posptr = ptr + pos->col;
|
posptr = ptr + pos->col;
|
||||||
if (has_mbyte)
|
if (has_mbyte)
|
||||||
// always start on the first byte
|
// always start on the first byte
|
||||||
|
@@ -1053,4 +1053,12 @@ func Test_using_visual_position()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_using_invalid_visual_position()
|
||||||
|
" this was going beyond the end of the line
|
||||||
|
new
|
||||||
|
exe "norm 0o000\<Esc>0\<C-V>$s0"
|
||||||
|
/\%V
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -749,6 +749,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3950,
|
||||||
/**/
|
/**/
|
||||||
3949,
|
3949,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user