summaryrefslogtreecommitdiffstats
path: root/src/if_perl.xs
diff options
context:
space:
mode:
Diffstat (limited to 'src/if_perl.xs')
-rw-r--r--src/if_perl.xs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/if_perl.xs b/src/if_perl.xs
index 5a29c1b87b..ecb9726e3b 100644
--- a/src/if_perl.xs
+++ b/src/if_perl.xs
@@ -1286,6 +1286,7 @@ ex_perldo(exarg_T *eap)
SV *sv;
char *str;
linenr_T i;
+ buf_T *was_curbuf = curbuf;
if (bufempty())
return;
@@ -1321,11 +1322,14 @@ ex_perldo(exarg_T *eap)
SAVETMPS;
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));
PUSHMARK(sp);
perl_call_pv("VIM::perldo", G_SCALAR | G_EVAL);
str = SvPV(GvSV(PL_errgv), length);
- if (length)
+ if (length || curbuf != was_curbuf)
break;
SPAGAIN;
if (SvTRUEx(POPs))