Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fs.lua): pass path to vim.fs.find function predicate and lazy evaluate the predicate #22378

Merged
merged 7 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions runtime/doc/lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2360,11 +2360,11 @@ find({names}, {opts}) *vim.fs.find()*
specifying {type} to be "file" or "directory", respectively.

Parameters: ~
• {names} (string|table|fun(name: string): boolean) Names of the files
and directories to find. Must be base names, paths and globs
are not supported. The function is called per file and
directory within the traversed directories to test if they
match {names}.
• {names} (string|table|fun(name: string, path: string): boolean) Names
of the files and directories to find. Must be base names,
paths and globs are not supported. The function is called per
file and directory within the traversed directories to test
if they match {names}.
• {opts} (table) Optional keyword arguments:
• path (string): Path to begin searching from. If omitted,
the |current-directory| is used.
Expand Down
4 changes: 2 additions & 2 deletions runtime/lua/vim/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ end
--- The search can be narrowed to find only files or only directories by
--- specifying {type} to be "file" or "directory", respectively.
---
---@param names (string|table|fun(name: string): boolean) Names of the files
---@param names (string|table|fun(name: string, path: string): boolean) Names of the files
justinmk marked this conversation as resolved.
Show resolved Hide resolved
--- and directories to find.
--- Must be base names, paths and globs are not supported.
--- The function is called per file and directory within the
Expand Down Expand Up @@ -201,7 +201,7 @@ function M.find(names, opts)
test = function(p)
local t = {}
for name, type in M.dir(p) do
if names(name) and (not opts.type or opts.type == type) then
if (not opts.type or opts.type == type) and names(name, p) then
table.insert(t, join_paths(p, name))
end
end
Expand Down