File tree Expand file tree Collapse file tree 4 files changed +17
-24
lines changed
Expand file tree Collapse file tree 4 files changed +17
-24
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11local M = {}
22
33M .change_dir = require (" nvim-tree.actions.root.change-dir" )
4- M .dir_up = require (" nvim-tree.actions.root.dir-up" )
54
65function M .setup (opts )
76 M .change_dir .setup (opts )
Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ Api.tree.change_root_to_node = wrap_node(function(node)
168168 end
169169end )
170170
171- Api .tree .change_root_to_parent = wrap_node (actions . root . dir_up . fn )
171+ Api .tree .change_root_to_parent = wrap_node (wrap_explorer ( " dir_up" ) )
172172Api .tree .get_node_under_cursor = wrap_explorer (" get_node_at_cursor" )
173173Api .tree .get_nodes = wrap_explorer (" get_nodes" )
174174
Original file line number Diff line number Diff line change @@ -659,6 +659,22 @@ function Explorer:get_nodes_by_line(line_start)
659659 return nodes_by_line
660660end
661661
662+ --- @param node Node
663+ function Explorer :dir_up (node )
664+ if not node or node .name == " .." then
665+ require (" nvim-tree.actions.root.change-dir" ).fn (" .." )
666+ else
667+ local cwd = core .get_cwd ()
668+ if cwd == nil then
669+ return
670+ end
671+
672+ local newdir = vim .fn .fnamemodify (utils .path_remove_trailing (cwd ), " :h" )
673+ require (" nvim-tree.actions.root.change-dir" ).fn (newdir )
674+ require (" nvim-tree.actions.finders.find-file" ).fn (node .absolute_path )
675+ end
676+ end
677+
662678--- Api.tree.get_nodes
663679--- @return nvim_tree.api.Node
664680function Explorer :get_nodes ()
You can’t perform that action at this time.
0 commit comments