fix(file_search): path with spaces in finddir() and findfile() (#25493)

Co-authored-by: dundargoc <gocdundar@gmail.com>
This commit is contained in:
Leonardo Mello 2023-10-09 19:08:58 -03:00 committed by GitHub
parent 4ab2b43c8f
commit 81f67b79e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 3 deletions

View File

@ -1,10 +1,10 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
local eval = helpers.eval
local command = helpers.command
local insert = helpers.insert
local feed = helpers.feed
local insert = helpers.insert
local is_os = helpers.is_os
local mkdir = helpers.mkdir
local rmdir = helpers.rmdir
@ -130,3 +130,40 @@ describe('file search (gf, <cfile>)', function()
test_cfile([[\\127.0.0.1\c$\temp\test-file.txt]], [[127.0.0.1]], [[\\127.0.0.1\c$\temp\test-file.txt]])
end)
end)
describe('file search with vim functions', function()
local test_folder = "path_spec_folder"
setup(function()
mkdir(test_folder)
end)
teardown(function()
rmdir(test_folder)
end)
---@param option "dir" | "file"
local function test_find_func(option, folder, item)
local folder_path = join_path(test_folder, folder)
mkdir(folder_path)
local expected = join_path(folder_path, item)
if option == "dir" then
mkdir(expected)
else
write_file(expected, '')
end
eq(expected, eval('find'..option..'(fnameescape(\''..item..'\'),fnameescape(\''..folder_path..'\'))'))
end
it('finddir()', function()
test_find_func('dir', 'directory', 'folder')
-- test_find_func('dir', 'directory', 'folder name')
test_find_func('dir', 'folder name', 'directory')
end)
it('findfile()', function()
test_find_func('file', 'directory', 'file.txt')
-- test_find_func('file', 'directory', 'file name.txt')
test_find_func('file', 'folder name', 'file.txt')
end)
end)