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

fix(filepattern): the pattern only matches filenames, not full paths #449

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
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 lua/pl/dir.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ local remove = os.remove
local append = table.insert
local assert_arg,assert_string,raise = utils.assert_arg,utils.assert_string,utils.raise

local exists, isdir = path.exists, path.isdir
local exists, isdir, basename = path.exists, path.isdir, path.basename
local sep = path.sep

local dir = {}
Expand Down Expand Up @@ -47,7 +47,7 @@ end
function dir.fnmatch(filename,pattern)
assert_string(1,filename)
assert_string(2,pattern)
return path.normcase(filename):find(filemask(pattern)) ~= nil
return path.normcase(basename(filename)):find(filemask(pattern)) ~= nil
end

--- Return a list of all file names within an array which match a pattern.
Expand All @@ -61,7 +61,7 @@ function dir.filter(filenames,pattern)
local res = {}
local mask = filemask(pattern)
for i,f in ipairs(filenames) do
if path.normcase(f):find(mask) then append(res,f) end
if path.normcase(basename(f)):find(mask) then append(res,f) end
end
return makelist(res)
end
Expand Down Expand Up @@ -94,7 +94,7 @@ function dir.getfiles(dirname,mask)
if mask then
mask = filemask(mask)
match = function(f)
return path.normcase(f):find(mask)
return path.normcase(basename(f)):find(mask)
end
end
return _listfiles(dirname,true,match)
Expand Down Expand Up @@ -515,7 +515,7 @@ function dir.getallfiles( start_path, shell_pattern )
for filename, mode in dir.dirtree( start_path ) do
if not mode then
local mask = filemask( shell_pattern )
if normcase(filename):find( mask ) then
if normcase(basename(filename)):find( mask ) then
files[#files + 1] = filename
end
end
Expand Down