Patch 8.1.0511
Problem:    ml_get error when calling a function with a range.
Solution:   Don't position the cursor after the last line.
Files:      src/userfunc.c, src/testdir/test_functions.vim


*** ../vim-8.1.0510/src/userfunc.c      2018-10-25 13:31:33.833906872 +0200
--- src/userfunc.c      2018-11-04 23:38:59.813826045 +0100
***************
*** 3149,3154 ****
--- 3149,3161 ----
      {
        if (!eap->skip && eap->addr_count > 0)
        {
+           if (lnum > curbuf->b_ml.ml_line_count)
+           {
+               // If the function deleted lines or switched to another buffer
+               // the line number may become invalid.
+               EMSG(_(e_invrange));
+               break;
+           }
            curwin->w_cursor.lnum = lnum;
            curwin->w_cursor.col = 0;
  #ifdef FEAT_VIRTUALEDIT
*** ../vim-8.1.0510/src/testdir/test_functions.vim      2018-10-07 
18:43:02.524682045 +0200
--- src/testdir/test_functions.vim      2018-11-04 23:33:21.703374164 +0100
***************
*** 1119,1121 ****
--- 1119,1140 ----
    call assert_fails('call Fsandbox()', 'E48:')
    delfunc Fsandbox
  endfunc
+ 
+ func EditAnotherFile()
+   let word = expand('<cword>')
+   edit Xfuncrange2
+ endfunc
+ 
+ func Test_func_range_with_edit()
+   " Define a function that edits another buffer, then call it with a range 
that
+   " is invalid in that buffer.
+   call writefile(['just one line'], 'Xfuncrange2')
+   new
+   call setline(1, range(10))
+   write Xfuncrange1
+   call assert_fails('5,8call EditAnotherFile()', 'E16:')
+ 
+   call delete('Xfuncrange1')
+   call delete('Xfuncrange2')
+   bwipe!
+ endfunc
*** ../vim-8.1.0510/src/version.c       2018-11-04 14:40:42.347139567 +0100
--- src/version.c       2018-11-04 23:36:30.146573147 +0100
***************
*** 794,795 ****
--- 794,797 ----
  {   /* Add new patch number below this line */
+ /**/
+     511,
  /**/

-- 
Proverb: A nightingale that forgets the lyrics is a hummingbird.

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui