mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.1189: invalid memory access with folding and using "L" (#21787)
Problem: Invalid memory access with folding and using "L".
Solution: Prevent the cursor from moving to line zero.
232bdaaca9
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
fd3d30a22c
commit
b884d0b370
@ -3645,8 +3645,10 @@ static void nv_scroll(cmdarg_T *cap)
|
|||||||
&& curwin->w_cursor.lnum > curwin->w_topline; n--) {
|
&& curwin->w_cursor.lnum > curwin->w_topline; n--) {
|
||||||
(void)hasFolding(curwin->w_cursor.lnum,
|
(void)hasFolding(curwin->w_cursor.lnum,
|
||||||
&curwin->w_cursor.lnum, NULL);
|
&curwin->w_cursor.lnum, NULL);
|
||||||
|
if (curwin->w_cursor.lnum > curwin->w_topline) {
|
||||||
curwin->w_cursor.lnum--;
|
curwin->w_cursor.lnum--;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
curwin->w_cursor.lnum -= (linenr_T)cap->count1 - 1;
|
curwin->w_cursor.lnum -= (linenr_T)cap->count1 - 1;
|
||||||
}
|
}
|
||||||
|
@ -1475,4 +1475,12 @@ func Test_sort_closed_fold()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_indent_with_L_command()
|
||||||
|
" The "L" command moved the cursor to line zero, causing the text saved for
|
||||||
|
" undo to use line number -1, which caused trouble for undo later.
|
||||||
|
new
|
||||||
|
sil! norm 8R
V{zf8=Lu
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user