Patch 8.2.0078

11 views
Skip to first unread message

Bram Moolenaar

unread,
Jan 2, 2020, 8:32:08 AM1/2/20
to vim...@googlegroups.com

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 -- Br...@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 ///
Reply all
Reply to author
Forward
0 new messages