Fix error in dirname computation in TreeView

In TreeView:on_mouse_pressed() we need to find the directory a
relative filename belongs to from its absolute filename.
The code was using string.find to locate the relative filename
within the absolute path but in some very specific cases we can
find a pattern which is not the right-most one leading to a
wrong directory name.

Fix the error by adding a loop to make sure we find the right-most
match. The standard Lua library has not a string.rfind to make a
reverse search.

Add a check to avoid trying to updating a topdir project directory.
This commit is contained in:
Francesco Abbate
2021-06-17 23:39:26 +02:00
parent 4fc910dbdb
commit 66275fe207
2 changed files with 22 additions and 3 deletions
+10
View File
@@ -194,6 +194,16 @@ local function project_scan_thread()
end
function core.is_project_folder(dirname)
for _, dir in ipairs(core.project_directories) do
if dir.name == dirname then
return true
end
end
return false
end
function core.scan_project_folder(dirname, filename)
for _, dir in ipairs(core.project_directories) do
if dir.name == dirname then