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 1 commit
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
8 changes: 3 additions & 5 deletions lua/neo-tree/sources/buffers/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ 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)
end
local node = state.tree:get_node()
local id = node.type == "directory" and node.id or node._parent_id
buffers.navigate(state, id)
end

cc._add_common_commands(M)
Expand Down
13 changes: 6 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,13 @@ 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()
local id = node.type == "directory" and node.id or node._parent_id
cseickel marked this conversation as resolved.
Show resolved Hide resolved
fs._navigate_internal(state, id, nil, nil, false)
end

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