Problem: The cursor line number becomes negative when using :z^ in an empty
buffer. (neovim #6557)
Solution: Correct the line number. Also reset the column.
if (curs > curbuf->b_ml.ml_line_count)
curs = curbuf->b_ml.ml_line_count;
+ else if (curs < 1)
+ curs = 1;
for (i = start; i <= end; i++)
{
}
}
- curwin->w_cursor.lnum = curs;
+ if (curwin->w_cursor.lnum != curs)
+ {
+ curwin->w_cursor.lnum = curs;
+ curwin->w_cursor.col = 0;
+ }
ex_no_reprint = TRUE;
}
bw!
endfunc
-func Test_z_bug()
+func Test_z_overflow()
" This used to access invalid memory as a result of an integer overflow
" and freeze vim.
normal ox
z777777776666666
')
endfunc
+
+func Test_z_negative_lnum()
+ new
+ z^
+ call assert_equal(1, line('.'))
+ bwipe!
+endfunc
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 571,
/**/
570,
/**/