mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.0.0571: negative line number when using :z^ in an empty buffer
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.
This commit is contained in:
@@ -4664,6 +4664,8 @@ ex_z(exarg_T *eap)
|
|||||||
|
|
||||||
if (curs > curbuf->b_ml.ml_line_count)
|
if (curs > curbuf->b_ml.ml_line_count)
|
||||||
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++)
|
for (i = start; i <= end; i++)
|
||||||
{
|
{
|
||||||
@@ -4686,7 +4688,11 @@ ex_z(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (curwin->w_cursor.lnum != curs)
|
||||||
|
{
|
||||||
curwin->w_cursor.lnum = curs;
|
curwin->w_cursor.lnum = curs;
|
||||||
|
curwin->w_cursor.col = 0;
|
||||||
|
}
|
||||||
ex_no_reprint = TRUE;
|
ex_no_reprint = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -68,7 +68,7 @@ func Test_z()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_z_bug()
|
func Test_z_overflow()
|
||||||
" This used to access invalid memory as a result of an integer overflow
|
" This used to access invalid memory as a result of an integer overflow
|
||||||
" and freeze vim.
|
" and freeze vim.
|
||||||
normal ox
|
normal ox
|
||||||
@@ -76,3 +76,10 @@ func Test_z_bug()
|
|||||||
z777777776666666
|
z777777776666666
|
||||||
')
|
')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_z_negative_lnum()
|
||||||
|
new
|
||||||
|
z^
|
||||||
|
call assert_equal(1, line('.'))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
@@ -764,6 +764,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
571,
|
||||||
/**/
|
/**/
|
||||||
570,
|
570,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user