commit 1b3c255f608a6c1a4a31bcd4a640ea6696403341
parent 5e9508c702739f1e8689446b5217e83feebe5942
Author: Eric Haynes <ehaynes99@gmail.com>
Date: Tue, 3 Jan 2023 12:24:14 -0500
fix(fs): duplicate path separator #21509
Fixes #21497
Diffstat:
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/runtime/lua/vim/fs.lua b/runtime/lua/vim/fs.lua
@@ -74,7 +74,7 @@ end
---@private
local function join_paths(...)
- return table.concat({ ... }, '/')
+ return (table.concat({ ... }, '/'):gsub('//+', '/'))
end
--- Return an iterator over the files and directories located in {path}
diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua
@@ -230,6 +230,11 @@ describe('vim.fs', function()
local dir, nvim = ...
return vim.fs.find(nvim, { path = dir, type = 'file' })
]], test_build_dir, nvim_prog_basename))
+ eq({nvim_dir}, exec_lua([[
+ local dir = ...
+ local parent, name = dir:match('^(.*/)([^/]+)$')
+ return vim.fs.find(name, { path = parent, upward = true, type = 'directory' })
+ ]], nvim_dir))
end)
it('accepts predicate as names', function()