Patch 8.0.0269
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.
Files:      src/if_perl.xs, src/testdir/test_perl.vim


*** ../vim-8.0.0268/src/if_perl.xs      2016-08-29 22:42:20.000000000 +0200
--- src/if_perl.xs      2017-01-29 22:57:17.286108890 +0100
***************
*** 1286,1291 ****
--- 1286,1292 ----
      SV                *sv;
      char      *str;
      linenr_T  i;
+     buf_T     *was_curbuf = curbuf;
  
      if (bufempty())
        return;
***************
*** 1321,1331 ****
      SAVETMPS;
      for (i = eap->line1; i <= eap->line2; i++)
      {
        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)
            break;
        SPAGAIN;
        if (SvTRUEx(POPs))
--- 1322,1335 ----
      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 || curbuf != was_curbuf)
            break;
        SPAGAIN;
        if (SvTRUEx(POPs))
*** ../vim-8.0.0268/src/testdir/test_perl.vim   2016-04-15 21:16:00.000000000 
+0200
--- src/testdir/test_perl.vim   2017-01-29 22:52:45.871907395 +0100
***************
*** 82,87 ****
--- 82,102 ----
    1
    call assert_false(search('\Cperl'))
    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
  
  function Test_VIM_package()
*** ../vim-8.0.0268/src/version.c       2017-01-29 22:48:26.401622036 +0100
--- src/version.c       2017-01-29 22:58:25.081659542 +0100
***************
*** 766,767 ****
--- 766,769 ----
  {   /* Add new patch number below this line */
+ /**/
+     269,
  /**/

-- 
When I look deep into your eyes, I see JPEG artifacts.
I can tell by the pixels that we're wrong for each other.  (xkcd)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui