0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 8.2.4956: reading past end of line with "gf" in Visual block mode

Problem:    Reading past end of line with "gf" in Visual block mode.
Solution:   Do not include the NUL in the length.
This commit is contained in:
Bram Moolenaar
2022-05-14 21:29:44 +01:00
parent 788c06a249
commit 395bd1f6d3
3 changed files with 27 additions and 3 deletions

View File

@@ -3671,9 +3671,16 @@ get_visual_text(
}
if (**pp == NUL)
*lenp = 0;
if (has_mbyte && *lenp > 0)
// Correct the length to include all bytes of the last character.
*lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1;
if (*lenp > 0)
{
if (has_mbyte)
// Correct the length to include all bytes of the last
// character.
*lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1;
else if ((*pp)[*lenp - 1] == NUL)
// Do not include a trailing NUL.
*lenp -= 1;
}
}
reset_VIsual_and_resel();
return OK;