aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2022-01-03 23:43:12 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2022-01-09 23:26:11 +0100
commita703840068c59758bfbde2e207d19d5c10600b2e (patch)
tree002fb84f7b48a8d6701ce045181662bdb3cf0f3e
parent295c65da92cd7bb3690f04629ebbffda5ff6c6a0 (diff)
downloadlite-xl-a703840068c59758bfbde2e207d19d5c10600b2e.tar.gz
lite-xl-a703840068c59758bfbde2e207d19d5c10600b2e.zip
Add some comments for ignore_files logic
-rw-r--r--data/core/init.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/data/core/init.lua b/data/core/init.lua
index c17f0498..fcd66734 100644
--- a/data/core/init.lua
+++ b/data/core/init.lua
@@ -122,6 +122,7 @@ local function compare_file(a, b)
end
+-- inspect config.ignore_files patterns and prepare ready to use entries.
local function compile_ignore_files()
local ipatterns = config.ignore_files
local compiled = {}
@@ -131,8 +132,8 @@ local function compile_ignore_files()
local match_dir = pattern:match("(.+)/$")
compiled[i] = {
use_path = pattern:match("/[^/]"), -- contains a slash but not at the end
- match_dir = match_dir,
- pattern = match_dir or pattern
+ match_dir = match_dir, -- to be used as a boolen value
+ pattern = match_dir or pattern -- get the actual pattern
}
end
return compiled
@@ -625,11 +626,13 @@ local function project_scan_add_file(dir, filepath)
local ignore = compile_ignore_files()
local fileinfo = get_project_file_info(dir.name, PATHSEP .. filepath, ignore)
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
filepath = common.dirname(filepath)
local parent_info = filepath and get_project_file_info(dir.name, PATHSEP .. filepath, ignore)
if filepath and not parent_info then
- return
+ return -- parent directory does match ignore_files rules: stop there
end
until not parent_info
project_scan_add_entry(dir, fileinfo)