Remove files from project list when collapsed

Only in limited files mode. We now symmetrically add the files if
a folder is expanded and remove them if it is collapsed.
This commit is contained in:
Francesco Abbate 2021-09-26 22:45:00 +02:00
parent 958703de02
commit 5c4bfd9a77
2 changed files with 4 additions and 5 deletions

View File

@ -323,16 +323,17 @@ local function rescan_project_subdir(dir, filename_rooted)
end end
function core.scan_project_subdir(dir, filename) function core.update_project_subdir(dir, filename, expanded)
local index, n, file = project_subdir_bounds(dir, filename) local index, n, file = project_subdir_bounds(dir, filename)
if index then if index then
local new_files = get_directory_files(dir, dir.name, PATHSEP .. filename, {}) local new_files = expanded and get_directory_files(dir, dir.name, PATHSEP .. filename, {}) or {}
files_list_replace(dir.files, index, n, new_files) files_list_replace(dir.files, index, n, new_files)
dir.is_dirty = true dir.is_dirty = true
return true return true
end end
end end
-- Find files and directories recursively reading from the filesystem. -- Find files and directories recursively reading from the filesystem.
-- Filter files and yields file's directory and info table. This latter -- Filter files and yields file's directory and info table. This latter
-- is filled to be like required by project directories "files" list. -- is filled to be like required by project directories "files" list.

View File

@ -216,9 +216,7 @@ function TreeView:on_mouse_pressed(button, x, y, clicks)
else else
hovered_item.expanded = not hovered_item.expanded hovered_item.expanded = not hovered_item.expanded
if hovered_item.dir.files_limit then if hovered_item.dir.files_limit then
if hovered_item.expanded then core.update_project_subdir(hovered_item.dir, hovered_item.filename, hovered_item.expanded)
core.scan_project_subdir(hovered_item.dir, hovered_item.filename)
end
print("DEBUG setting show flag to", hovered_item.expanded) print("DEBUG setting show flag to", hovered_item.expanded)
core.project_subdir_set_show(hovered_item.dir, hovered_item.filename, hovered_item.expanded) core.project_subdir_set_show(hovered_item.dir, hovered_item.filename, hovered_item.expanded)
end end