Patch 8.2.0078
Problem:    Expanding <sfile> works differently the second time.
Solution:   Keep the expanded name when redefining a function. (closes #5425)
Files:      src/testdir/test_vimscript.vim, src/userfunc.c


*** ../vim-8.2.0077/src/testdir/test_vimscript.vim      2019-11-08 
22:56:32.000000000 +0100
--- src/testdir/test_vimscript.vim      2020-01-02 14:20:35.587460239 +0100
***************
*** 1642,1647 ****
--- 1642,1664 ----
    enew! | close
  endfunc
  
+ func Test_script_expand_sfile()
+   let lines =<< trim END
+     func s:snr()
+       return expand('<sfile>')
+     endfunc
+     let g:result = s:snr()
+   END
+   call writefile(lines, 'Xexpand')
+   source Xexpand
+   call assert_match('<SNR>\d\+_snr', g:result)
+   source Xexpand
+   call assert_match('<SNR>\d\+_snr', g:result)
+ 
+   call delete('Xexpand')
+   unlet g:result
+ endfunc
+ 
  func Test_compound_assignment_operators()
      " Test for number
      let x = 1
*** ../vim-8.2.0077/src/userfunc.c      2019-12-31 21:27:09.555256491 +0100
--- src/userfunc.c      2020-01-02 14:29:38.429274544 +0100
***************
*** 2572,2580 ****
            }
            else
            {
!               // redefine existing function
                VIM_CLEAR(name);
                func_clear_items(fp);
  #ifdef FEAT_PROFILE
                fp->uf_profiling = FALSE;
                fp->uf_prof_initialized = FALSE;
--- 2572,2584 ----
            }
            else
            {
!               char_u *exp_name = fp->uf_name_exp;
! 
!               // redefine existing function, keep the expanded name
                VIM_CLEAR(name);
+               fp->uf_name_exp = NULL;
                func_clear_items(fp);
+               fp->uf_name_exp = exp_name;
  #ifdef FEAT_PROFILE
                fp->uf_profiling = FALSE;
                fp->uf_prof_initialized = FALSE;
*** ../vim-8.2.0077/src/version.c       2020-01-02 14:02:12.316159489 +0100
--- src/version.c       2020-01-02 14:30:32.201059305 +0100
***************
*** 744,745 ****
--- 744,747 ----
  {   /* Add new patch number below this line */
+ /**/
+     78,
  /**/

-- 
TIM: But follow only if you are men of valour.  For the entrance to this cave
     is guarded by a monster, a creature so foul and cruel that no man yet has
     fought with it and lived.  Bones of full fifty men lie strewn about its
     lair ...
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202001021331.002DVoZx031580%40masaka.moolenaar.net.

Raspunde prin e-mail lui