mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(source): make changing 'shellslash' change expand() result
This commit is contained in:
parent
d6a6adf708
commit
9ab9eb1220
@ -1906,7 +1906,7 @@ void nlua_set_sctx(sctx_T *current)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
char *source_path = fix_fname(info->source + 1);
|
char *source_path = fix_fname(info->source + 1);
|
||||||
get_current_script_id((char_u *)source_path, current);
|
get_current_script_id(&source_path, current);
|
||||||
xfree(source_path);
|
xfree(source_path);
|
||||||
current->sc_lnum = info->currentline;
|
current->sc_lnum = info->currentline;
|
||||||
current->sc_seq = -1;
|
current->sc_seq = -1;
|
||||||
|
@ -1964,7 +1964,7 @@ int do_source(char *fname, int check_other, int is_vimrc)
|
|||||||
save_funccal(&funccalp_entry);
|
save_funccal(&funccalp_entry);
|
||||||
|
|
||||||
const sctx_T save_current_sctx = current_sctx;
|
const sctx_T save_current_sctx = current_sctx;
|
||||||
si = get_current_script_id((char_u *)fname_exp, ¤t_sctx);
|
si = get_current_script_id(&fname_exp, ¤t_sctx);
|
||||||
|
|
||||||
if (l_do_profiling == PROF_YES) {
|
if (l_do_profiling == PROF_YES) {
|
||||||
bool forceit = false;
|
bool forceit = false;
|
||||||
@ -2077,9 +2077,9 @@ theend:
|
|||||||
/// Check if fname was sourced before to finds its SID.
|
/// Check if fname was sourced before to finds its SID.
|
||||||
/// If it's new, generate a new SID.
|
/// If it's new, generate a new SID.
|
||||||
///
|
///
|
||||||
/// @param[in] fname file path of script
|
/// @param[in,out] fnamep pointer to file path of script
|
||||||
/// @param[out] ret_sctx sctx of this script
|
/// @param[out] ret_sctx sctx of this script
|
||||||
scriptitem_T *get_current_script_id(char_u *fname, sctx_T *ret_sctx)
|
scriptitem_T *get_current_script_id(char **fnamep, sctx_T *ret_sctx)
|
||||||
{
|
{
|
||||||
static int last_current_SID_seq = 0;
|
static int last_current_SID_seq = 0;
|
||||||
|
|
||||||
@ -2096,13 +2096,14 @@ scriptitem_T *get_current_script_id(char_u *fname, sctx_T *ret_sctx)
|
|||||||
// - If a script is deleted and another script is written, with a
|
// - If a script is deleted and another script is written, with a
|
||||||
// different name, the inode may be re-used.
|
// different name, the inode may be re-used.
|
||||||
si = &SCRIPT_ITEM(script_sctx.sc_sid);
|
si = &SCRIPT_ITEM(script_sctx.sc_sid);
|
||||||
if (si->sn_name != NULL && FNAMECMP(si->sn_name, fname) == 0) {
|
if (si->sn_name != NULL && FNAMECMP(si->sn_name, *fnamep) == 0) {
|
||||||
// Found it!
|
// Found it!
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (script_sctx.sc_sid == 0) {
|
if (script_sctx.sc_sid == 0) {
|
||||||
si = new_script_item((char *)vim_strsave(fname), &script_sctx.sc_sid);
|
si = new_script_item(*fnamep, &script_sctx.sc_sid);
|
||||||
|
*fnamep = xstrdup((char *)si->sn_name);
|
||||||
}
|
}
|
||||||
if (ret_sctx != NULL) {
|
if (ret_sctx != NULL) {
|
||||||
*ret_sctx = script_sctx;
|
*ret_sctx = script_sctx;
|
||||||
|
@ -13,6 +13,10 @@ local exec_lua = helpers.exec_lua
|
|||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
local exec_capture = helpers.exec_capture
|
local exec_capture = helpers.exec_capture
|
||||||
local neq = helpers.neq
|
local neq = helpers.neq
|
||||||
|
local matches = helpers.matches
|
||||||
|
local iswin = helpers.iswin
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
local rmdir = helpers.rmdir
|
||||||
|
|
||||||
describe(':source', function()
|
describe(':source', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
@ -39,6 +43,30 @@ describe(':source', function()
|
|||||||
os.remove(test_file)
|
os.remove(test_file)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("changing 'shellslash' changes the result of expand()", function()
|
||||||
|
if not iswin() then
|
||||||
|
pending("'shellslash' only works on Windows")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
mkdir('Xshellslash')
|
||||||
|
local script = [[
|
||||||
|
let g:result1 = expand('<stack>')
|
||||||
|
set shellslash
|
||||||
|
let g:result2 = expand('<stack>')
|
||||||
|
set noshellslash
|
||||||
|
let g:result3 = expand('<stack>')
|
||||||
|
]]
|
||||||
|
write_file([[Xshellslash/Xexpand.vim]], script)
|
||||||
|
|
||||||
|
meths.set_option('shellslash', false)
|
||||||
|
command([[source Xshellslash/Xexpand.vim]])
|
||||||
|
matches([[Xshellslash\Xexpand%.vim]], meths.get_var('result1'))
|
||||||
|
matches([[Xshellslash/Xexpand%.vim]], meths.get_var('result2'))
|
||||||
|
matches([[Xshellslash\Xexpand%.vim]], meths.get_var('result3'))
|
||||||
|
|
||||||
|
rmdir('Xshellslash')
|
||||||
|
end)
|
||||||
|
|
||||||
it('current buffer', function()
|
it('current buffer', function()
|
||||||
insert([[
|
insert([[
|
||||||
let a = 2
|
let a = 2
|
||||||
|
Loading…
Reference in New Issue
Block a user