Mercurial > vim
comparison src/if_perl.xs @ 10759:4267f8904d47 v8.0.0269
patch 8.0.0269: may get ml_get error when :perldo deletes lines
commit https://github.com/vim/vim/commit/85b5743d3e69f96882b6124d4b4ebf873ca24707
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 29 22:59:12 2017 +0100
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 https://github.com/vim/vim/issues/1421)
Solution: Check the buffer and line every time.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 29 Jan 2017 23:00:05 +0100 |
parents | 4aead6a9b7a9 |
children | 778c10516955 |
comparison
equal
deleted
inserted
replaced
10758:35314ebe9e57 | 10759:4267f8904d47 |
---|---|
1284 { | 1284 { |
1285 STRLEN length; | 1285 STRLEN length; |
1286 SV *sv; | 1286 SV *sv; |
1287 char *str; | 1287 char *str; |
1288 linenr_T i; | 1288 linenr_T i; |
1289 buf_T *was_curbuf = curbuf; | |
1289 | 1290 |
1290 if (bufempty()) | 1291 if (bufempty()) |
1291 return; | 1292 return; |
1292 | 1293 |
1293 if (perl_interp == NULL) | 1294 if (perl_interp == NULL) |
1319 | 1320 |
1320 ENTER; | 1321 ENTER; |
1321 SAVETMPS; | 1322 SAVETMPS; |
1322 for (i = eap->line1; i <= eap->line2; i++) | 1323 for (i = eap->line1; i <= eap->line2; i++) |
1323 { | 1324 { |
1325 /* Check the line number, the command my have deleted lines. */ | |
1326 if (i > curbuf->b_ml.ml_line_count) | |
1327 break; | |
1324 sv_setpv(GvSV(PL_defgv), (char *)ml_get(i)); | 1328 sv_setpv(GvSV(PL_defgv), (char *)ml_get(i)); |
1325 PUSHMARK(sp); | 1329 PUSHMARK(sp); |
1326 perl_call_pv("VIM::perldo", G_SCALAR | G_EVAL); | 1330 perl_call_pv("VIM::perldo", G_SCALAR | G_EVAL); |
1327 str = SvPV(GvSV(PL_errgv), length); | 1331 str = SvPV(GvSV(PL_errgv), length); |
1328 if (length) | 1332 if (length || curbuf != was_curbuf) |
1329 break; | 1333 break; |
1330 SPAGAIN; | 1334 SPAGAIN; |
1331 if (SvTRUEx(POPs)) | 1335 if (SvTRUEx(POPs)) |
1332 { | 1336 { |
1333 if (replace_line(&i, &eap->line2) != OK) | 1337 if (replace_line(&i, &eap->line2) != OK) |