Skip to content

fix(#2794): sshfs compatibility #2922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lua/nvim-tree/actions/fs/remove-file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,18 @@ local function remove_dir(cwd)
end

while true do
local name, t = vim.loop.fs_scandir_next(handle)
local name, _ = vim.loop.fs_scandir_next(handle)
if not name then
break
end

local new_cwd = utils.path_join { cwd, name }
if t == "directory" then

-- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility
local stat = vim.loop.fs_stat(new_cwd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be fs_lstat?

Copy link
Collaborator Author

@mxple mxple Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary but we can change for consistency.

local type = stat and stat.type or nil

if type == "directory" then
local success = remove_dir(new_cwd)
if not success then
return false
Expand Down
13 changes: 9 additions & 4 deletions lua/nvim-tree/explorer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,22 @@ function Explorer:reload(node, git_status)
})

while true do
local name, t = vim.loop.fs_scandir_next(handle)
local name, _ = vim.loop.fs_scandir_next(handle)
if not name then
break
end

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

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

-- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility
local t = stat and stat.type or nil

-- Recreate node if type changes.
if nodes_by_path[abs] then
local n = nodes_by_path[abs]
Expand Down Expand Up @@ -351,7 +354,7 @@ function Explorer:populate_children(handle, cwd, node, git_status, parent)
})

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

---@type uv.fs_stat.result|nil
local stat = vim.loop.fs_stat(abs)
local stat = vim.loop.fs_lstat(abs)
local filter_reason = parent.filters:should_filter_as_reason(abs, stat, filter_status)
if filter_reason == FILTER_REASON.none and not nodes_by_path[abs] then
-- Type must come from fs_stat and not fs_scandir_next to maintain sshfs compatibility
local t = stat and stat.type or nil
local child = nil
if t == "directory" and vim.loop.fs_access(abs, "R") then
child = builders.folder(node, abs, name, stat)
Expand Down
Loading