summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-15 17:53:55 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-15 17:53:55 +0100
commit5a4fff4d948cd12a5cf5f637ad2c561815a77d8e (patch)
tree81c53805f751b3f53f0c018f9af2215ba2a0c000 /src
parentcce293f87beb57a75ff738fade7fafadbc4a78a9 (diff)
downloadvim-git-5a4fff4d948cd12a5cf5f637ad2c561815a77d8e.tar.gz
patch 9.0.0217: 'shellslash' works differently when sourcing a script againv9.0.0217
Problem: 'shellslash' works differently when sourcing a script again. Solution: Use the name from the script item. (closes #10920)
Diffstat (limited to 'src')
-rw-r--r--src/scriptfile.c8
-rw-r--r--src/testdir/test_expand_func.vim27
-rw-r--r--src/version.c2
3 files changed, 32 insertions, 5 deletions
diff --git a/src/scriptfile.c b/src/scriptfile.c
index 952f2efd0..053dd0647 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -1534,10 +1534,6 @@ do_source_ext(
cookie.level = ex_nesting_level;
#endif
- // Keep the sourcing name/lnum, for recursive calls.
- estack_push(ETYPE_SCRIPT, fname_exp, 0);
- ESTACK_CHECK_SETUP
-
#ifdef STARTUPTIME
if (time_fd != NULL)
time_push(&tv_rel, &tv_start);
@@ -1630,6 +1626,10 @@ do_source_ext(
si->sn_is_vimrc = is_vimrc;
}
+ // Keep the sourcing name/lnum, for recursive calls.
+ estack_push(ETYPE_SCRIPT, si->sn_name, 0);
+ ESTACK_CHECK_SETUP
+
# ifdef FEAT_PROFILE
if (do_profiling == PROF_YES)
{
diff --git a/src/testdir/test_expand_func.vim b/src/testdir/test_expand_func.vim
index d9327bf3e..454d76f0a 100644
--- a/src/testdir/test_expand_func.vim
+++ b/src/testdir/test_expand_func.vim
@@ -41,7 +41,7 @@ func Test_expand_sfile_and_stack()
call assert_match('test_expand_func\.vim$', s:sfile)
let expected = 'script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack'
call assert_match(expected .. '$', expand('<sfile>'))
- call assert_match(expected .. '\[4\]' , expand('<stack>'))
+ call assert_match(expected .. '\[4\]$' , expand('<stack>'))
" Call in script-local function
call assert_match('script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack\[7\]\.\.<SNR>\d\+_expand_sfile$', s:expand_sfile())
@@ -59,7 +59,32 @@ func Test_expand_sfile_and_stack()
call writefile(lines, 'Xstack')
source Xstack
call assert_match('\<Xstack\[2\]$', g:stack_value)
+ unlet g:stack_value
call delete('Xstack')
+
+ if exists('+shellslash')
+ call mkdir('Xshellslash')
+ let lines =<< trim END
+ let g:stack1 = expand('<stack>')
+ set noshellslash
+ let g:stack2 = expand('<stack>')
+ set shellslash
+ let g:stack3 = expand('<stack>')
+ END
+ call writefile(lines, 'Xshellslash/Xstack')
+ " Test that changing 'shellslash' always affects the result of expand()
+ " when sourcing a script multiple times.
+ for i in range(2)
+ source Xshellslash/Xstack
+ call assert_match('\<Xshellslash/Xstack\[1\]$', g:stack1)
+ call assert_match('\<Xshellslash\\Xstack\[3\]$', g:stack2)
+ call assert_match('\<Xshellslash/Xstack\[5\]$', g:stack3)
+ unlet g:stack1
+ unlet g:stack2
+ unlet g:stack3
+ endfor
+ call delete('Xshellslash', 'rf')
+ endif
endfunc
func Test_expand_slnum()
diff --git a/src/version.c b/src/version.c
index a48533068..5c7e3a93a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 217,
+/**/
216,
/**/
215,