Skip to content

Commit 9650e73

Browse files
mxplealex-courtis
andauthored
fix(#2794): sshfs compatibility (#2922)
* Revert "revert(#2794): sshfs compatibility (#2920)" This reverts commit 8405ecf. Fix for symlinks is simple * fix sshfs compatibility with symlinks * add suggestions * revert variable name change to ease multi-instance feature branch conflicts --------- Co-authored-by: Alexander Courtis <[email protected]>
1 parent 59a8a6a commit 9650e73

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

lua/nvim-tree/actions/fs/remove-file.lua

+7-2
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,18 @@ local function remove_dir(cwd)
5757
end
5858

5959
while true do
60-
local name, t = vim.loop.fs_scandir_next(handle)
60+
local name, _ = vim.loop.fs_scandir_next(handle)
6161
if not name then
6262
break
6363
end
6464

6565
local new_cwd = utils.path_join { cwd, name }
66-
if t == "directory" then
66+
67+
-- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility
68+
local stat = vim.loop.fs_stat(new_cwd)
69+
local type = stat and stat.type or nil
70+
71+
if type == "directory" then
6772
local success = remove_dir(new_cwd)
6873
if not success then
6974
return false

lua/nvim-tree/explorer/init.lua

+9-4
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,22 @@ function Explorer:reload(node, git_status)
125125
})
126126

127127
while true do
128-
local name, t = vim.loop.fs_scandir_next(handle)
128+
local name, _ = vim.loop.fs_scandir_next(handle)
129129
if not name then
130130
break
131131
end
132132

133133
local abs = utils.path_join { cwd, name }
134134
---@type uv.fs_stat.result|nil
135-
local stat = vim.loop.fs_stat(abs)
135+
local stat = vim.loop.fs_lstat(abs)
136136

137137
local filter_reason = self.filters:should_filter_as_reason(abs, stat, filter_status)
138138
if filter_reason == FILTER_REASON.none then
139139
remain_childs[abs] = true
140140

141+
-- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility
142+
local t = stat and stat.type or nil
143+
141144
-- Recreate node if type changes.
142145
if nodes_by_path[abs] then
143146
local n = nodes_by_path[abs]
@@ -351,7 +354,7 @@ function Explorer:populate_children(handle, cwd, node, git_status, parent)
351354
})
352355

353356
while true do
354-
local name, t = vim.loop.fs_scandir_next(handle)
357+
local name, _ = vim.loop.fs_scandir_next(handle)
355358
if not name then
356359
break
357360
end
@@ -362,9 +365,11 @@ function Explorer:populate_children(handle, cwd, node, git_status, parent)
362365
local profile = log.profile_start("populate_children %s", abs)
363366

364367
---@type uv.fs_stat.result|nil
365-
local stat = vim.loop.fs_stat(abs)
368+
local stat = vim.loop.fs_lstat(abs)
366369
local filter_reason = parent.filters:should_filter_as_reason(abs, stat, filter_status)
367370
if filter_reason == FILTER_REASON.none and not nodes_by_path[abs] then
371+
-- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility
372+
local t = stat and stat.type or nil
368373
local child = nil
369374
if t == "directory" and vim.loop.fs_access(abs, "R") then
370375
child = builders.folder(node, abs, name, stat)

0 commit comments

Comments
 (0)