mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
patch 8.0.0269: may get ml_get error when :perldo deletes lines
Problem: May get ml_get error when :perldo deletes lines or switches to another buffer. (Nikolai Pavlov, issue #1421) Solution: Check the buffer and line every time.
This commit is contained in:
@@ -1286,6 +1286,7 @@ ex_perldo(exarg_T *eap)
|
|||||||
SV *sv;
|
SV *sv;
|
||||||
char *str;
|
char *str;
|
||||||
linenr_T i;
|
linenr_T i;
|
||||||
|
buf_T *was_curbuf = curbuf;
|
||||||
|
|
||||||
if (bufempty())
|
if (bufempty())
|
||||||
return;
|
return;
|
||||||
@@ -1321,11 +1322,14 @@ ex_perldo(exarg_T *eap)
|
|||||||
SAVETMPS;
|
SAVETMPS;
|
||||||
for (i = eap->line1; i <= eap->line2; i++)
|
for (i = eap->line1; i <= eap->line2; i++)
|
||||||
{
|
{
|
||||||
|
/* Check the line number, the command my have deleted lines. */
|
||||||
|
if (i > curbuf->b_ml.ml_line_count)
|
||||||
|
break;
|
||||||
sv_setpv(GvSV(PL_defgv), (char *)ml_get(i));
|
sv_setpv(GvSV(PL_defgv), (char *)ml_get(i));
|
||||||
PUSHMARK(sp);
|
PUSHMARK(sp);
|
||||||
perl_call_pv("VIM::perldo", G_SCALAR | G_EVAL);
|
perl_call_pv("VIM::perldo", G_SCALAR | G_EVAL);
|
||||||
str = SvPV(GvSV(PL_errgv), length);
|
str = SvPV(GvSV(PL_errgv), length);
|
||||||
if (length)
|
if (length || curbuf != was_curbuf)
|
||||||
break;
|
break;
|
||||||
SPAGAIN;
|
SPAGAIN;
|
||||||
if (SvTRUEx(POPs))
|
if (SvTRUEx(POPs))
|
||||||
|
@@ -82,6 +82,21 @@ function Test_perldo()
|
|||||||
1
|
1
|
||||||
call assert_false(search('\Cperl'))
|
call assert_false(search('\Cperl'))
|
||||||
bw!
|
bw!
|
||||||
|
|
||||||
|
" Check deleting lines does not trigger ml_get error.
|
||||||
|
new
|
||||||
|
call setline(1, ['one', 'two', 'three'])
|
||||||
|
perldo VIM::DoCommand("%d_")
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" Check switching to another buffer does not trigger ml_get error.
|
||||||
|
new
|
||||||
|
let wincount = winnr('$')
|
||||||
|
call setline(1, ['one', 'two', 'three'])
|
||||||
|
perldo VIM::DoCommand("new")
|
||||||
|
call assert_equal(wincount + 1, winnr('$'))
|
||||||
|
bwipe!
|
||||||
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
function Test_VIM_package()
|
function Test_VIM_package()
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
269,
|
||||||
/**/
|
/**/
|
||||||
268,
|
268,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user