mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 21:48:35 +00:00
vim-patch:9.0.0217: 'shellslash' works differently when sourcing a script again
Problem: 'shellslash' works differently when sourcing a script again.
Solution: Use the name from the script item. (closes vim/vim#10920)
5a4fff4d94
This commit is contained in:
@@ -1941,9 +1941,6 @@ int do_source(char *fname, int check_other, int is_vimrc)
|
|||||||
|
|
||||||
cookie.level = ex_nesting_level;
|
cookie.level = ex_nesting_level;
|
||||||
|
|
||||||
// Keep the sourcing name/lnum, for recursive calls.
|
|
||||||
estack_push(ETYPE_SCRIPT, fname_exp, 0);
|
|
||||||
|
|
||||||
// start measuring script load time if --startuptime was passed and
|
// start measuring script load time if --startuptime was passed and
|
||||||
// time_fd was successfully opened afterwards.
|
// time_fd was successfully opened afterwards.
|
||||||
proftime_T rel_time;
|
proftime_T rel_time;
|
||||||
@@ -1966,6 +1963,9 @@ int do_source(char *fname, int check_other, int is_vimrc)
|
|||||||
const sctx_T save_current_sctx = current_sctx;
|
const sctx_T save_current_sctx = current_sctx;
|
||||||
si = get_current_script_id(&fname_exp, ¤t_sctx);
|
si = get_current_script_id(&fname_exp, ¤t_sctx);
|
||||||
|
|
||||||
|
// Keep the sourcing name/lnum, for recursive calls.
|
||||||
|
estack_push(ETYPE_SCRIPT, (char *)si->sn_name, 0);
|
||||||
|
|
||||||
if (l_do_profiling == PROF_YES) {
|
if (l_do_profiling == PROF_YES) {
|
||||||
bool forceit = false;
|
bool forceit = false;
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ func Test_expand_sfile_and_stack()
|
|||||||
call assert_match('test_expand_func\.vim$', s:sfile)
|
call assert_match('test_expand_func\.vim$', s:sfile)
|
||||||
let expected = 'script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack'
|
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 .. '$', expand('<sfile>'))
|
||||||
call assert_match(expected .. '\[4\]' , expand('<stack>'))
|
call assert_match(expected .. '\[4\]$' , expand('<stack>'))
|
||||||
|
|
||||||
" Call in script-local function
|
" 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())
|
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')
|
call writefile(lines, 'Xstack')
|
||||||
source Xstack
|
source Xstack
|
||||||
call assert_match('\<Xstack\[2\]$', g:stack_value)
|
call assert_match('\<Xstack\[2\]$', g:stack_value)
|
||||||
|
unlet g:stack_value
|
||||||
call delete('Xstack')
|
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
|
endfunc
|
||||||
|
|
||||||
func Test_expand_slnum()
|
func Test_expand_slnum()
|
||||||
|
Reference in New Issue
Block a user