mirror of
https://github.com/neovim/neovim.git
synced 2026-07-23 01:12:49 +00:00
fix(path): normalize separators (slashes) #39155
Problem: Continue separators normalization, and try to keep it at the nvim <-> external boundary, e.g., `fn.xxx`, `api.xxx`, `:xxx` Solution: some key changes - normalize `$HOME-windows` - normalize entry points of changing directory - `nvim_set_current_dir()`, `chdir()` - normalize the named pipe - `--listen` arg, `--server` arg, `:restart` - `serverstart()`, `sockconnect()`, `serverstop()` - make `expand()` respect 'shellslash' again - clean up `did_set_shellslash` - replace `forward_slash` with `TO_SLASH` - remove obsolete `TMP_PATHSEPSTR` - remove `slash_adjust` in `do_autocmd_dirchanged`? - make `fnamemodify()` always return `/` (except when substituting separators via `:s`, `:gs` ?) Note: - these funcs still apply `slash_adjust` on return, as before: `:pwd`, `chdir()`, `exepath()`, `getcwd()` - these funcs alwarys return `/`, unlike before the normalization PRs - `getcompletion()`, `finddir()`, `findfile()` Also - clean up code, comments, formatting and tests - move `TO_SLASH` from `f_chdir` to `changedir_func` - move `TO_SLASH` from `f_bufadd` to `buflist_new` Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
This commit is contained in:
@@ -2,7 +2,7 @@ local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local eq, clear, call, write_file, command = t.eq, n.clear, n.call, t.write_file, n.command
|
||||
local eval = n.eval
|
||||
local eval, fn = n.eval, n.fn
|
||||
local is_os = t.is_os
|
||||
local pcall_err = t.pcall_err
|
||||
|
||||
@@ -18,38 +18,26 @@ describe('executable()', function()
|
||||
eq(1, call('executable', 'false'))
|
||||
end)
|
||||
|
||||
if is_os('win') then
|
||||
it('exepath returns consistent slashes #13787', function()
|
||||
-- test/ cannot be a symlink in this test.
|
||||
n.api.nvim_set_current_dir(t.paths.test_source_path)
|
||||
it('exepath respects shellslash #13787', function()
|
||||
t.skip(not is_os('win'), 'N/A for non-Windows')
|
||||
-- test/ cannot be a symlink in this test.
|
||||
n.api.nvim_set_current_dir(t.paths.test_source_path)
|
||||
|
||||
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)
|
||||
command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")')
|
||||
eq(([[%s\test\functional\fixtures\bin\null.CMD]]):format(fn.getcwd()), fn.exepath('null'))
|
||||
command('set shellslash')
|
||||
eq(('%s/test/functional/fixtures/bin/null.CMD'):format(fn.getcwd()), fn.exepath('null'))
|
||||
end)
|
||||
|
||||
it('stdpath returns consistent slashes #13787', function()
|
||||
-- Needs to check paths relative to repo root dir.
|
||||
n.api.nvim_set_current_dir(t.paths.test_source_path)
|
||||
it('stdpath returns consistent slashes #13787', function()
|
||||
t.skip(not is_os('win'), 'N/A for non-Windows')
|
||||
-- Needs to check paths relative to repo root dir.
|
||||
n.api.nvim_set_current_dir(t.paths.test_source_path)
|
||||
|
||||
t.matches(
|
||||
[[build/Xtest_xdg[%w_]*/share/nvim%-data]],
|
||||
call('fnamemodify', call('stdpath', 'data'), ':.')
|
||||
)
|
||||
command('set shellslash')
|
||||
t.matches(
|
||||
'build/Xtest_xdg[%w_]*/share/nvim%-data',
|
||||
call('fnamemodify', call('stdpath', 'data'), ':.')
|
||||
)
|
||||
end)
|
||||
end
|
||||
t.matches('build/Xtest_xdg[%w_]*/share/nvim%-data', fn.stdpath('data'))
|
||||
command('set shellslash')
|
||||
t.matches('build/Xtest_xdg[%w_]*/share/nvim%-data', fn.stdpath('data'))
|
||||
end)
|
||||
|
||||
it('fails for invalid values', function()
|
||||
for _, input in ipairs({ 'v:null', 'v:true', 'v:false', '{}', '[]' }) do
|
||||
|
||||
Reference in New Issue
Block a user