[filesystem] collapse_directory #258
Answered
by
cseickel
MunifTanjim
asked this question in
Q&A
-
How do I do this? collapse_directory = function(state)
local node = state.tree:get_node()
if node.type ~= "directory" or not node:is_expanded() then
node = state.tree:get_node(node:get_parent_id())
end
if node.type == "directory" then
-- collapse node
-- focus node
end
end, I want to collapse a directory and then focus it. |
Beta Was this translation helpful? Give feedback.
Answered by
cseickel
Apr 10, 2022
Replies: 2 comments 2 replies
-
The collapse is just the standard NuiNode collapse followed by a NuiTree render. The focus node method is a custom Neo-tree function: collapse_directory = function(state)
local node = state.tree:get_node()
if node.type ~= "directory" or not node:is_expanded() then
node = state.tree:get_node(node:get_parent_id())
end
if node.type == "directory" then
-- collapse node
node:collapse()
state.tree:render()
-- focus node
require("neo-tree.ui.renderer").focus_node(state, node:get_id())
end
end, |
Beta Was this translation helpful? Give feedback.
0 replies
-
What I should have said was that this functionality already exists, it is the |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
MunifTanjim
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What I should have said was that this functionality already exists, it is the
"close_node"
command, mapped toC
by default. That built-in function also works with nested files.