Skip to content
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

feat(set_root): allow filesystem and buffers to run set_root when the cursor is on both files and directories #1420

Merged
merged 6 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions lua/neo-tree/sources/buffers/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,17 @@ M.rename = function(state)
end

M.set_root = function(state)
local tree = state.tree
local node = tree:get_node()
if node.type == "directory" then
buffers.navigate(state, node.id)
local node = state.tree:get_node()
if not node then
return
end

local id = node.type == "directory" and node:get_id() or node:get_parent_id()
if not id then
return
end

buffers.navigate(state, id)
end

cc._add_common_commands(M)
Expand Down
21 changes: 14 additions & 7 deletions lua/neo-tree/sources/filesystem/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,21 @@ M.rename = function(state)
end

M.set_root = function(state)
local tree = state.tree
local node = tree:get_node()
if node.type == "directory" then
if state.search_pattern then
fs.reset_search(state, false)
end
fs._navigate_internal(state, node.id, nil, nil, false)
if state.search_pattern then
fs.reset_search(state, false)
end

local node = state.tree:get_node()
if not node then
return
end

local id = node.type == "directory" and node:get_id() or node:get_parent_id()
cseickel marked this conversation as resolved.
Show resolved Hide resolved
if not id then
return
end

fs._navigate_internal(state, id, nil, nil, false)
end

---Toggles whether hidden files are shown or not.
Expand Down