Skip to content

Commit 85b5743

Browse files
committed
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.
1 parent d58f03b commit 85b5743

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/if_perl.xs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,7 @@ ex_perldo(exarg_T *eap)
12861286
SV *sv;
12871287
char *str;
12881288
linenr_T i;
1289+
buf_T *was_curbuf = curbuf;
12891290

12901291
if (bufempty())
12911292
return;
@@ -1321,11 +1322,14 @@ ex_perldo(exarg_T *eap)
13211322
SAVETMPS;
13221323
for (i = eap->line1; i <= eap->line2; i++)
13231324
{
1325+
/* Check the line number, the command my have deleted lines. */
1326+
if (i > curbuf->b_ml.ml_line_count)
1327+
break;
13241328
sv_setpv(GvSV(PL_defgv), (char *)ml_get(i));
13251329
PUSHMARK(sp);
13261330
perl_call_pv("VIM::perldo", G_SCALAR | G_EVAL);
13271331
str = SvPV(GvSV(PL_errgv), length);
1328-
if (length)
1332+
if (length || curbuf != was_curbuf)
13291333
break;
13301334
SPAGAIN;
13311335
if (SvTRUEx(POPs))

src/testdir/test_perl.vim

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ function Test_perldo()
8282
1
8383
call assert_false(search('\Cperl'))
8484
bw!
85+
86+
" Check deleting lines does not trigger ml_get error.
87+
new
88+
call setline(1, ['one', 'two', 'three'])
89+
perldo VIM::DoCommand("%d_")
90+
bwipe!
91+
92+
" Check switching to another buffer does not trigger ml_get error.
93+
new
94+
let wincount = winnr('$')
95+
call setline(1, ['one', 'two', 'three'])
96+
perldo VIM::DoCommand("new")
97+
call assert_equal(wincount + 1, winnr('$'))
98+
bwipe!
99+
bwipe!
85100
endfunc
86101

87102
function Test_VIM_package()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
269,
767769
/**/
768770
268,
769771
/**/

0 commit comments

Comments
 (0)