mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(windows):exepath, stdpath return wrong slashes #19111
exepath and stdpath should respect shellslash and return path with proper file separator. Closes #13787
This commit is contained in:
parent
776913e32e
commit
1b462705d0
@ -2048,6 +2048,12 @@ static void f_exepath(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
|
|
||||||
(void)os_can_exe(tv_get_string(&argvars[0]), &path, true);
|
(void)os_can_exe(tv_get_string(&argvars[0]), &path, true);
|
||||||
|
|
||||||
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
|
if (path != NULL) {
|
||||||
|
slash_adjust((char_u *)path);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
rettv->vval.v_string = path;
|
rettv->vval.v_string = path;
|
||||||
}
|
}
|
||||||
|
@ -115,6 +115,10 @@ char *get_xdg_home(const XDGVarType idx)
|
|||||||
#else
|
#else
|
||||||
dir = concat_fnames_realloc(dir, "nvim", true);
|
dir = concat_fnames_realloc(dir, "nvim", true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
|
slash_adjust((char_u *)dir);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ local iswin = helpers.iswin
|
|||||||
local startswith = helpers.startswith
|
local startswith = helpers.startswith
|
||||||
local write_file = helpers.write_file
|
local write_file = helpers.write_file
|
||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
|
local alter_slashes = helpers.alter_slashes
|
||||||
|
|
||||||
local testfile = 'Xtest_startuptime'
|
local testfile = 'Xtest_startuptime'
|
||||||
after_each(function()
|
after_each(function()
|
||||||
@ -33,9 +34,9 @@ end)
|
|||||||
describe('startup', function()
|
describe('startup', function()
|
||||||
it('--clean', function()
|
it('--clean', function()
|
||||||
clear()
|
clear()
|
||||||
ok(string.find(meths.get_option('runtimepath'), funcs.stdpath('config'), 1, true) ~= nil)
|
ok(string.find(alter_slashes(meths.get_option('runtimepath')), funcs.stdpath('config'), 1, true) ~= nil)
|
||||||
clear('--clean')
|
clear('--clean')
|
||||||
ok(string.find(meths.get_option('runtimepath'), funcs.stdpath('config'), 1, true) == nil)
|
ok(string.find(alter_slashes(meths.get_option('runtimepath')), funcs.stdpath('config'), 1, true) == nil)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('--startuptime', function()
|
it('--startuptime', function()
|
||||||
|
@ -17,6 +17,21 @@ describe('executable()', function()
|
|||||||
eq(1, call('executable', 'false'))
|
eq(1, call('executable', 'false'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
if iswin() then
|
||||||
|
it('exepath respects shellslash', function()
|
||||||
|
command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")')
|
||||||
|
eq([[test\functional\fixtures\bin\null.CMD]], call('fnamemodify', call('exepath', 'null'), ':.'))
|
||||||
|
command('set shellslash')
|
||||||
|
eq('test/functional/fixtures/bin/null.CMD', call('fnamemodify', call('exepath', 'null'), ':.'))
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('stdpath respects shellslash', function()
|
||||||
|
eq([[build\Xtest_xdg\share\nvim-data]], call('fnamemodify', call('stdpath', 'data'), ':.'))
|
||||||
|
command('set shellslash')
|
||||||
|
eq('build/Xtest_xdg/share/nvim-data', call('fnamemodify', call('stdpath', 'data'), ':.'))
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
it('fails for invalid values', function()
|
it('fails for invalid values', function()
|
||||||
for _, input in ipairs({'v:null', 'v:true', 'v:false', '{}', '[]'}) do
|
for _, input in ipairs({'v:null', 'v:true', 'v:false', '{}', '[]'}) do
|
||||||
eq('Vim(call):E928: String required', exc_exec('call executable('..input..')'))
|
eq('Vim(call):E928: String required', exc_exec('call executable('..input..')'))
|
||||||
|
Loading…
Reference in New Issue
Block a user