From 1b3c255f608a6c1a4a31bcd4a640ea6696403341 Mon Sep 17 00:00:00 2001 From: Eric Haynes Date: Tue, 3 Jan 2023 12:24:14 -0500 Subject: [PATCH] fix(fs): duplicate path separator #21509 Fixes #21497 --- runtime/lua/vim/fs.lua | 2 +- test/functional/lua/fs_spec.lua | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/lua/vim/fs.lua b/runtime/lua/vim/fs.lua index 89a1d0d345..65e6ca677c 100644 --- 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 index 20a1660b0e..642d36f63a 100644 --- 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()