File tree Expand file tree Collapse file tree 2 files changed +15
-14
lines changed
Expand file tree Collapse file tree 2 files changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ local notify = require("nvim-tree.notify")
1010
1111local DirectoryNode = require (" nvim-tree.node.directory" )
1212local FileLinkNode = require (" nvim-tree.node.file-link" )
13- local FileNode = require (" nvim-tree.node.file" )
1413local RootNode = require (" nvim-tree.node.root" )
1514local UserDecorator = require (" nvim-tree.renderer.decorator.user" )
1615
@@ -158,19 +157,7 @@ Api.tree.change_root = wrap(function(...)
158157 require (" nvim-tree" ).change_dir (... )
159158end )
160159
161- Api .tree .change_root_to_node = wrap_node (function (node )
162- if node .name == " .." or node :is (RootNode ) then
163- wrap_explorer (" change_dir" )(" .." )
164- elseif node :is (FileNode ) and node .parent ~= nil then
165- wrap_explorer (" change_dir" )(node .parent :last_group_node ().absolute_path )
166- else
167- node = node :as (DirectoryNode )
168- if node then
169- wrap_explorer (" change_dir" )(node :last_group_node ().absolute_path )
170- end
171- end
172- end )
173-
160+ Api .tree .change_root_to_node = wrap_node (wrap_explorer (" change_dir_to_node" ))
174161Api .tree .change_root_to_parent = wrap_node (wrap_explorer (" dir_up" ))
175162Api .tree .get_node_under_cursor = wrap_explorer (" get_node_at_cursor" )
176163Api .tree .get_nodes = wrap_explorer (" get_nodes" )
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ local LiveFilter = require("nvim-tree.explorer.live-filter")
2020local Sorter = require (" nvim-tree.explorer.sorter" )
2121local Clipboard = require (" nvim-tree.actions.fs.clipboard" )
2222local Renderer = require (" nvim-tree.renderer" )
23+ local FileNode = require (" nvim-tree.node.file" )
2324
2425local FILTER_REASON = require (" nvim-tree.enum" ).FILTER_REASON
2526local find_file = require (" nvim-tree.actions.finders.find-file" )
@@ -773,6 +774,19 @@ function Explorer:change_dir(input_cwd, with_open)
773774 self :force_dirchange (foldername , with_open )
774775end
775776
777+ function Explorer :change_dir_to_node (node )
778+ if node .name == " .." or node :is (RootNode ) then
779+ self :change_dir (" .." )
780+ elseif node :is (FileNode ) and node .parent ~= nil then
781+ self :change_dir (node .parent :last_group_node ().absolute_path )
782+ else
783+ node = node :as (DirectoryNode )
784+ if node then
785+ self :change_dir (node :last_group_node ().absolute_path )
786+ end
787+ end
788+ end
789+
776790function Explorer :setup (opts )
777791 config = opts
778792end
You can’t perform that action at this time.
0 commit comments