From 7d5532ebe40bea00942c1a4f3c5372b7c4c9d85f Mon Sep 17 00:00:00 2001 From: Pablo Ariel Mayobre Date: Fri, 19 May 2017 04:01:05 -0300 Subject: [PATCH] Fix issue #36 and #44 This issue was related to Lua not handling coroutines iterators right, the function being recursive generated multiple coroutine iterators and they didn't resume right. The solution is to make the first loop non-recursive and create a secondary loop where the recursive function is called. --- src/project.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/project.lua b/src/project.lua index 2abf761..434096a 100644 --- a/src/project.lua +++ b/src/project.lua @@ -62,20 +62,25 @@ end -- @local local _buildFileTree _buildFileTree = function(dir) - local subDir + local subDirs = {} + for file in assert(fs.dir()) do if not file:find("^%.git") then if fs.is_dir(file) then - subDir = {} - dir[file] = subDir - assert(fs.change_dir(file)) - _buildFileTree(subDir, file) - assert(fs.pop_dir()) + subDirs[#subDirs + 1] = file elseif fs.is_file(file) then dir[#dir+1] = file end end end + + for _, path in ipairs(subDirs) do + local newDir = {} + dir[path] = newDir + assert(fs.change_dir(path)) + _buildFileTree(newDir) + assert(fs.pop_dir()) + end end --- Recursive function to check if file should be excluded based