Add some comments for ignore_files logic
This commit is contained in:
parent
295c65da92
commit
a703840068
|
@ -122,6 +122,7 @@ local function compare_file(a, b)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- inspect config.ignore_files patterns and prepare ready to use entries.
|
||||||
local function compile_ignore_files()
|
local function compile_ignore_files()
|
||||||
local ipatterns = config.ignore_files
|
local ipatterns = config.ignore_files
|
||||||
local compiled = {}
|
local compiled = {}
|
||||||
|
@ -131,8 +132,8 @@ local function compile_ignore_files()
|
||||||
local match_dir = pattern:match("(.+)/$")
|
local match_dir = pattern:match("(.+)/$")
|
||||||
compiled[i] = {
|
compiled[i] = {
|
||||||
use_path = pattern:match("/[^/]"), -- contains a slash but not at the end
|
use_path = pattern:match("/[^/]"), -- contains a slash but not at the end
|
||||||
match_dir = match_dir,
|
match_dir = match_dir, -- to be used as a boolen value
|
||||||
pattern = match_dir or pattern
|
pattern = match_dir or pattern -- get the actual pattern
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
return compiled
|
return compiled
|
||||||
|
@ -625,11 +626,13 @@ local function project_scan_add_file(dir, filepath)
|
||||||
local ignore = compile_ignore_files()
|
local ignore = compile_ignore_files()
|
||||||
local fileinfo = get_project_file_info(dir.name, PATHSEP .. filepath, ignore)
|
local fileinfo = get_project_file_info(dir.name, PATHSEP .. filepath, ignore)
|
||||||
if fileinfo then
|
if fileinfo then
|
||||||
|
-- on Windows and MacOS we can get events from directories we are not following:
|
||||||
|
-- check if each parent directories pass the ignore_files rules.
|
||||||
repeat
|
repeat
|
||||||
filepath = common.dirname(filepath)
|
filepath = common.dirname(filepath)
|
||||||
local parent_info = filepath and get_project_file_info(dir.name, PATHSEP .. filepath, ignore)
|
local parent_info = filepath and get_project_file_info(dir.name, PATHSEP .. filepath, ignore)
|
||||||
if filepath and not parent_info then
|
if filepath and not parent_info then
|
||||||
return
|
return -- parent directory does match ignore_files rules: stop there
|
||||||
end
|
end
|
||||||
until not parent_info
|
until not parent_info
|
||||||
project_scan_add_entry(dir, fileinfo)
|
project_scan_add_entry(dir, fileinfo)
|
||||||
|
|
Loading…
Reference in New Issue