fix(#1520): file type changes are not detected. (#1521)

This commit is contained in:
Sebastian Volland 2022-08-22 03:41:11 +02:00 committed by GitHub
parent 81eb718394
commit c5fba1ec18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -11,6 +11,7 @@ function M.folder(parent, absolute_path, name)
local has_children = handle and uv.fs_scandir_next(handle) ~= nil
return {
type = "directory",
absolute_path = absolute_path,
fs_stat = uv.fs_stat(absolute_path),
group_next = nil, -- If node is grouped, this points to the next child dir/link node
@ -34,6 +35,7 @@ function M.file(parent, absolute_path, name)
local ext = string.match(name, ".?[^.]+%.(.*)") or ""
return {
type = "file",
absolute_path = absolute_path,
executable = M.is_executable(absolute_path, ext),
extension = ext,
@ -61,6 +63,7 @@ function M.link(parent, absolute_path, name)
end
return {
type = "link",
absolute_path = absolute_path,
fs_stat = uv.fs_stat(absolute_path),
group_next = nil, -- If node is grouped, this points to the next child dir/link node

View File

@ -45,6 +45,18 @@ function M.reload(node, status)
t = t or (uv.fs_stat(abs) or {}).type
if not filters.should_ignore(abs) and not filters.should_ignore_git(abs, status.files) then
child_names[abs] = true
-- Recreate node if type changes.
if nodes_by_path[abs] then
local n = nodes_by_path[abs]
if n.type ~= t then
utils.array_remove(node.nodes, n)
common.node_destroy(n)
nodes_by_path[abs] = nil
end
end
if not nodes_by_path[abs] then
if t == "directory" and uv.fs_access(abs, "R") then
local folder = builders.folder(node, abs, name)