diff options
-rw-r--r-- | core/file_io.lua | 17 | ||||
-rw-r--r-- | core/lfs_ext.lua | 34 | ||||
-rw-r--r-- | modules/textadept/find.lua | 19 |
3 files changed, 52 insertions, 18 deletions
diff --git a/core/file_io.lua b/core/file_io.lua index ba84b65e..14637891 100644 --- a/core/file_io.lua +++ b/core/file_io.lua @@ -383,10 +383,19 @@ io.snapopen_filters = {} -- obtained from `io.get_project_root()`. -- Files shown in the dialog do not match any pattern in either string or table -- *filter* or, unless *exclude_FILTER* is `true`, in `lfs.FILTER`. A filter --- table contains Lua patterns that match filenames to exclude, an optional --- `folders` sub-table that contains patterns matching directories to exclude, --- and an optional `extensions` sub-table that contains raw file extensions to --- exclude. Any patterns starting with '!' exclude files and directories that do +-- table contains: +-- +-- + Lua patterns that match filenames to exclude. +-- + Optional `folders` sub-table that contains patterns matching directories +-- to exclude. +-- + Optional `extensions` sub-table that contains raw file extensions to +-- exclude. +-- + Optional `symlink` flag that when `true`, excludes symlinked files (but +-- not symlinked directories). +-- + Optional `folders.symlink` flag that when `true`, excludes symlinked +-- directories. +-- +-- Any filter patterns starting with '!' exclude files and directories that do -- not match the pattern that follows. The number of files in the list is capped -- at `SNAPOPEN_MAX`. If *filter* is `nil` and *paths* is ultimately a string, -- the filter from the `io.snapopen_filters` table is used. In that case, unless diff --git a/core/lfs_ext.lua b/core/lfs_ext.lua index b3dda4f7..6cab4b11 100644 --- a/core/lfs_ext.lua +++ b/core/lfs_ext.lua @@ -21,6 +21,7 @@ lfs.FILTER = { folders = {'%.bzr$', '%.git$', '%.hg$', '%.svn$', 'CVS$'} } +local lfs_symlinkattributes = lfs.symlinkattributes -- Determines whether or not the given file matches the given filter. -- @param file The filename. -- @param filter The filter table. @@ -37,7 +38,7 @@ local function exclude(file, filter) if not file:find(patt:sub(2)) then return true end end end - return false + return filter.symlink and lfs_symlinkattributes(file, 'mode') == 'link' end --- @@ -45,11 +46,20 @@ end -- directory *dir*, calling function *f* with each file found. -- Files passed to *f* do not match any pattern in string or table *filter*, -- and, unless *exclude_FILTER* is `true`, `lfs.FILTER` as well. A filter table --- contains Lua patterns that match filenames to exclude, an optional `folders` --- sub-table that contains patterns matching directories to exclude, and an --- optional `extensions` sub-table that contains raw file extensions to exclude. --- Any patterns starting with '!' exclude files and directories that do not --- match the pattern that follows. +-- contains: +-- +-- + Lua patterns that match filenames to exclude. +-- + Optional `folders` sub-table that contains patterns matching directories +-- to exclude. +-- + Optional `extensions` sub-table that contains raw file extensions to +-- exclude. +-- + Optional `symlink` flag that when `true`, excludes symlinked files (but +-- not symlinked directories). +-- + Optional `folders.symlink` flag that when `true`, excludes symlinked +-- directories. +-- +-- Any filter patterns starting with '!' exclude files and directories that do +-- not match the pattern that follows. -- @param dir The directory path to iterate over. -- @param f Function to call with each full file path found. If *f* returns -- `false` explicitly, iteration ceases. @@ -77,9 +87,15 @@ function lfs.dir_foreach(dir, f, filter, exclude_FILTER, n, include_dirs, level) -- Add FILTER to filter unless specified otherwise. if not exclude_FILTER then for k, v in pairs(lfs.FILTER) do - if not filter[k] then filter[k] = {} end - local filter_k = filter[k] - for i = 1, #v do filter_k[#filter_k + 1] = v[i] end + if type(v) == 'table' then + if not filter[k] then filter[k] = {} end + local filter_k = filter[k] + for k2, v2 in pairs(v) do + filter_k[tonumber(k2) and #filter_k + 1 or k2] = v2 + end + else + filter[tonumber(k) and #filter + 1 or k] = v + end end end -- Create file extension filter hash table for quick lookups. diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index fe75107f..c5ef927d 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -81,11 +81,20 @@ local preferred_view --- -- The table of Lua patterns matching files and directories to exclude when -- finding in files. --- The filter contains Lua patterns that match filenames to exclude, an optional --- `folders` sub-table that contains patterns matching directories to exclude, --- and an optional `extensions` sub-table that contains raw file extensions to --- exclude. Any patterns starting with '!' exclude files and directories that do --- not match the pattern that follows. +-- The filter table contains: +-- +-- + Lua patterns that match filenames to exclude. +-- + Optional `folders` sub-table that contains patterns matching directories +-- to exclude. +-- + Optional `extensions` sub-table that contains raw file extensions to +-- exclude. +-- + Optional `symlink` flag that when `true`, excludes symlinked files (but +-- not symlinked directories). +-- + Optional `folders.symlink` flag that when `true`, excludes symlinked +-- directories. +-- +-- Any patterns starting with '!' exclude files and directories that do not +-- match the pattern that follows. -- The default value is `lfs.FILTER`, a filter for common binary file extensions -- and version control directories. -- @see find_in_files |