mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 07:28:34 +00:00
vim-patch:8.2.5013: after text formatting cursor may be in an invalid position
Problem: After text formatting the cursor may be in an invalid position.
Solution: Correct the cursor position after formatting.
78d52883e1
This commit is contained in:
@@ -4349,6 +4349,9 @@ static void op_format(oparg_T *oap, int keep_cursor)
|
||||
if (keep_cursor) {
|
||||
curwin->w_cursor = saved_cursor;
|
||||
saved_cursor.lnum = 0;
|
||||
|
||||
// formatting may have made the cursor position invalid
|
||||
check_cursor();
|
||||
}
|
||||
|
||||
if (oap->is_VIsual) {
|
||||
|
@@ -1534,4 +1534,16 @@ func Test_autoformat_comments()
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" This was leaving the cursor after the end of a line. Complicated way to
|
||||
" have the problem show up with valgrind.
|
||||
func Test_correct_cursor_position()
|
||||
" set encoding=iso8859
|
||||
new
|
||||
norm a0000
|
||||
sil! norm gggg0i0gw0gg
|
||||
|
||||
bwipe!
|
||||
set encoding=utf8
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Reference in New Issue
Block a user