Mercurial > vim
diff src/testdir/test_vimscript.vim @ 19035:b920ae62c7b1 v8.2.0078
patch 8.2.0078: expanding <sfile> works differently the second time
Commit: https://github.com/vim/vim/commit/b9adef79eca6f95bc7376ff3a6a383e436c5d6ea
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 2 14:31:22 2020 +0100
patch 8.2.0078: expanding <sfile> works differently the second time
Problem: Expanding <sfile> works differently the second time.
Solution: Keep the expanded name when redefining a function. (closes https://github.com/vim/vim/issues/5425)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 02 Jan 2020 14:45:03 +0100 |
parents | ed9690c0f27c |
children | 2a017e9dc6da |
line wrap: on
line diff
--- a/src/testdir/test_vimscript.vim +++ b/src/testdir/test_vimscript.vim @@ -1642,6 +1642,23 @@ func Test_script_local_func() 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