diff --git a/data/core/config.lua b/data/core/config.lua index 0115cab8..4f58f825 100644 --- a/data/core/config.lua +++ b/data/core/config.lua @@ -17,5 +17,6 @@ config.indent_size = 2 config.tab_type = "soft" config.line_limit = 80 config.max_symbols = 2000 +config.max_project_files = 2000 return config diff --git a/data/core/init.lua b/data/core/init.lua index fd0b70ec..72b294b8 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -34,6 +34,8 @@ local function project_scan_thread() local all = system.list_dir(path) or {} local dirs, files = {}, {} + local entries_count = 0 + local max_entries = config.max_project_files for _, file in ipairs(all) do if not common.match_pattern(file, config.ignore_files) then local file = (path ~= "." and path .. PATHSEP or "") .. file @@ -41,6 +43,8 @@ local function project_scan_thread() if info and info.size < size_limit then info.filename = file table.insert(info.type == "dir" and dirs or files, info) + entries_count = entries_count + 1 + if entries_count > max_entries then break end end end end @@ -48,7 +52,10 @@ local function project_scan_thread() table.sort(dirs, compare_file) for _, f in ipairs(dirs) do table.insert(t, f) - get_files(f.filename, t) + if entries_count <= max_entries then + local subdir_t, subdir_count = get_files(f.filename, t) + entries_count = entries_count + subdir_count + end end table.sort(files, compare_file) @@ -56,14 +63,19 @@ local function project_scan_thread() table.insert(t, f) end - return t + return t, entries_count end while true do -- get project files and replace previous table if the new table is -- different - local t = get_files(".") + local t, entries_count = get_files(".") if diff_files(core.project_files, t) then + if entries_count > config.max_project_files then + core.status_view:show_message("!", style.accent, + "Too many files in project directory: stopping reading at ".. + config.max_project_files.." files according to config.max_project_files.") + end core.project_files = t core.redraw = true end