Skip to content

Commit c82f200

Browse files
committed
fix(#1520) file type changes are not detected.
1 parent 09a5126 commit c82f200

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lua/nvim-tree/explorer/node-builders.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function M.folder(parent, absolute_path, name)
1111
local has_children = handle and uv.fs_scandir_next(handle) ~= nil
1212

1313
return {
14+
type = "directory",
1415
absolute_path = absolute_path,
1516
fs_stat = uv.fs_stat(absolute_path),
1617
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)
3435
local ext = string.match(name, ".?[^.]+%.(.*)") or ""
3536

3637
return {
38+
type = "file",
3739
absolute_path = absolute_path,
3840
executable = M.is_executable(absolute_path, ext),
3941
extension = ext,
@@ -61,6 +63,7 @@ function M.link(parent, absolute_path, name)
6163
end
6264

6365
return {
66+
type = "link",
6467
absolute_path = absolute_path,
6568
fs_stat = uv.fs_stat(absolute_path),
6669
group_next = nil, -- If node is grouped, this points to the next child dir/link node

lua/nvim-tree/explorer/reload.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ function M.reload(node, status)
4545
t = t or (uv.fs_stat(abs) or {}).type
4646
if not filters.should_ignore(abs) and not filters.should_ignore_git(abs, status.files) then
4747
child_names[abs] = true
48+
49+
-- Recreate node if type changes.
50+
if nodes_by_path[abs] then
51+
local n = nodes_by_path[abs]
52+
53+
if n.type ~= t then
54+
utils.array_remove(node.nodes, n)
55+
common.node_destroy(n)
56+
nodes_by_path[abs] = nil
57+
end
58+
end
59+
4860
if not nodes_by_path[abs] then
4961
if t == "directory" and uv.fs_access(abs, "R") then
5062
local folder = builders.folder(node, abs, name)

0 commit comments

Comments
 (0)