Skip to content

Commit 049cdd3

Browse files
authored
fix(#1518): sort_by=modification_time not reordering on refresh. (#1519)
1 parent c5fba1e commit 049cdd3

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

lua/nvim-tree/explorer/reload.lua

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,18 @@ function M.reload(node, status)
4141
break
4242
end
4343

44+
local stat
45+
local function fs_stat_cached(path)
46+
if stat ~= nil then
47+
return stat
48+
end
49+
50+
stat = uv.fs_stat(path)
51+
return stat
52+
end
53+
4454
local abs = utils.path_join { cwd, name }
45-
t = t or (uv.fs_stat(abs) or {}).type
55+
t = t or (fs_stat_cached(abs) or {}).type
4656
if not filters.should_ignore(abs) and not filters.should_ignore_git(abs, status.files) then
4757
child_names[abs] = true
4858

@@ -73,10 +83,12 @@ function M.reload(node, status)
7383
table.insert(node.nodes, link)
7484
end
7585
end
76-
end
77-
local n = nodes_by_path[abs]
78-
if n then
79-
n.executable = builders.is_executable(abs, n.extension or "")
86+
else
87+
local n = nodes_by_path[abs]
88+
if n then
89+
n.executable = builders.is_executable(abs, n.extension or "")
90+
n.fs_stat = fs_stat_cached(abs)
91+
end
8092
end
8193
end
8294
end

0 commit comments

Comments
 (0)