File tree Expand file tree Collapse file tree 4 files changed +19
-24
lines changed
Expand file tree Collapse file tree 4 files changed +19
-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 @@ -22,6 +22,8 @@ local Clipboard = require("nvim-tree.actions.fs.clipboard")
2222local Renderer = require (" nvim-tree.renderer" )
2323
2424local FILTER_REASON = require (" nvim-tree.enum" ).FILTER_REASON
25+ local change_dir = require (" nvim-tree.actions.root.change-dir" )
26+ local find_file = require (" nvim-tree.actions.finders.find-file" )
2527
2628local config
2729
@@ -659,6 +661,22 @@ function Explorer:get_nodes_by_line(line_start)
659661 return nodes_by_line
660662end
661663
664+ --- @param node Node
665+ function Explorer :dir_up (node )
666+ if not node or node .name == " .." then
667+ change_dir .fn (" .." )
668+ else
669+ local cwd = core .get_cwd ()
670+ if cwd == nil then
671+ return
672+ end
673+
674+ local newdir = vim .fn .fnamemodify (utils .path_remove_trailing (cwd ), " :h" )
675+ change_dir .fn (newdir )
676+ find_file .fn (node .absolute_path )
677+ end
678+ end
679+
662680--- Api.tree.get_nodes
663681--- @return nvim_tree.api.Node
664682function Explorer :get_nodes ()
You can’t perform that action at this time.
0 commit comments