aboutsummaryrefslogtreecommitdiff
path: root/data/plugins/treeview.lua
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2022-06-17 15:35:23 -0400
committerjgmdev <jgmdev@gmail.com>2022-06-17 15:35:23 -0400
commit173dd3aeb4891267e139dd752fada6c15abbdda9 (patch)
tree1b1ab0e9f4eb3d8341a420fa38749772061aa998 /data/plugins/treeview.lua
parent3c682512e70b7a3f1589f9645261c90106b512ec (diff)
downloadpragtical-173dd3aeb4891267e139dd752fada6c15abbdda9.tar.gz
pragtical-173dd3aeb4891267e139dd752fada6c15abbdda9.zip
plugin treeview: fix crash
When the max_project_files is set to a higher value than the allowed system maximum file descriptors, and opening a project directory that causes dirmonitor to open a watch on a lot of files or directories, at least on MacOSX it causes all system.* file functions to return nil (for too many opened files) which breaks the project files scan.
Diffstat (limited to 'data/plugins/treeview.lua')
-rw-r--r--data/plugins/treeview.lua42
1 files changed, 22 insertions, 20 deletions
diff --git a/data/plugins/treeview.lua b/data/plugins/treeview.lua
index bdcb0f49..cc13ec59 100644
--- a/data/plugins/treeview.lua
+++ b/data/plugins/treeview.lua
@@ -153,28 +153,30 @@ function TreeView:each_item()
count_lines = count_lines + 1
y = y + h
local i = 1
- while i <= #dir.files and dir_cached.expanded do
- local item = dir.files[i]
- local cached = self:get_cached(dir, item, dir.name)
-
- coroutine.yield(cached, ox, y, w, h)
- count_lines = count_lines + 1
- y = y + h
- i = i + 1
-
- if not cached.expanded then
- if cached.skip then
- i = cached.skip
- else
- local depth = cached.depth
- while i <= #dir.files do
- if get_depth(dir.files[i].filename) <= depth then break end
- i = i + 1
+ if dir.files then -- if consumed max sys file descriptors this can be nil
+ while i <= #dir.files and dir_cached.expanded do
+ local item = dir.files[i]
+ local cached = self:get_cached(dir, item, dir.name)
+
+ coroutine.yield(cached, ox, y, w, h)
+ count_lines = count_lines + 1
+ y = y + h
+ i = i + 1
+
+ if not cached.expanded then
+ if cached.skip then
+ i = cached.skip
+ else
+ local depth = cached.depth
+ while i <= #dir.files do
+ if get_depth(dir.files[i].filename) <= depth then break end
+ i = i + 1
+ end
+ cached.skip = i
end
- cached.skip = i
end
- end
- end -- while files
+ end -- while files
+ end
end -- for directories
self.count_lines = count_lines
end)