mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 08:18:17 +00:00
vim-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().
94f3192b03
This commit is contained in:
@@ -928,10 +928,12 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
|
|||||||
// continue until the NUL
|
// continue until the NUL
|
||||||
posptr = NULL;
|
posptr = NULL;
|
||||||
} else {
|
} else {
|
||||||
// Special check for an empty line, which can happen on exit, when
|
// In a few cases the position can be beyond the end of the line.
|
||||||
// ml_get_buf() always returns an empty string.
|
for (colnr_T i = 0; i < pos->col; i++) {
|
||||||
if (*ptr == NUL) {
|
if (ptr[i] == NUL) {
|
||||||
pos->col = 0;
|
pos->col = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
posptr = ptr + pos->col;
|
posptr = ptr + pos->col;
|
||||||
posptr -= utf_head_off(line, posptr);
|
posptr -= utf_head_off(line, posptr);
|
||||||
|
@@ -803,4 +803,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
|
||||||
|
Reference in New Issue
Block a user