mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
fix(fs.lua): normalize slash truncation (#23753)
Preserve last slash in windows' root drive directories
This commit is contained in:
parent
80cf0f3d29
commit
e4da418ba8
@ -348,7 +348,11 @@ function M.normalize(path, opts)
|
||||
path = path:gsub('%$([%w_]+)', vim.uv.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
|
||||
|
@ -301,5 +301,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)
|
||||
|
Loading…
Reference in New Issue
Block a user