mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
Merge pull request #24384 from neovim/backport-23753-to-release-0.9
[Backport release-0.9] fix(fs.lua): normalize slash truncation
This commit is contained in:
@@ -344,7 +344,11 @@ function M.normalize(path, opts)
|
||||
path = path:gsub('%$([%w_]+)', vim.loop.os_getenv)
|
||||
end
|
||||
|
||||
return (path:gsub('\\', '/'):gsub('/+', '/'):gsub('(.)/$', '%1'))
|
||||
path = path:gsub('\\', '/'):gsub('/+', '/')
|
||||
if iswin and path:match('^%w:/$') then
|
||||
return path
|
||||
end
|
||||
return (path:gsub('(.)/$', '%1'))
|
||||
end
|
||||
|
||||
return M
|
||||
|
@@ -290,5 +290,10 @@ describe('vim.fs', function()
|
||||
return vim.fs.normalize('$XDG_CONFIG_HOME/nvim')
|
||||
]], xdg_config_home))
|
||||
end)
|
||||
if is_os('win') then
|
||||
it('Last slash is not truncated from root drive', function()
|
||||
eq('C:/', exec_lua [[ return vim.fs.normalize('C:/') ]])
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user