Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 0 additions & 22 deletions lua/nvim-tree/actions/root/dir-up.lua

This file was deleted.

1 change: 0 additions & 1 deletion lua/nvim-tree/actions/root/init.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
local M = {}

M.change_dir = require("nvim-tree.actions.root.change-dir")
M.dir_up = require("nvim-tree.actions.root.dir-up")

function M.setup(opts)
M.change_dir.setup(opts)
Expand Down
2 changes: 1 addition & 1 deletion lua/nvim-tree/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Api.tree.change_root_to_node = wrap_node(function(node)
end
end)

Api.tree.change_root_to_parent = wrap_node(actions.root.dir_up.fn)
Api.tree.change_root_to_parent = wrap_node(wrap_explorer("dir_up"))
Api.tree.get_node_under_cursor = wrap_explorer("get_node_at_cursor")
Api.tree.get_nodes = wrap_explorer("get_nodes")

Expand Down
18 changes: 18 additions & 0 deletions lua/nvim-tree/explorer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ local Clipboard = require("nvim-tree.actions.fs.clipboard")
local Renderer = require("nvim-tree.renderer")

local FILTER_REASON = require("nvim-tree.enum").FILTER_REASON
local change_dir = require("nvim-tree.actions.root.change-dir")
local find_file = require("nvim-tree.actions.finders.find-file")

local config

Expand Down Expand Up @@ -659,6 +661,22 @@ function Explorer:get_nodes_by_line(line_start)
return nodes_by_line
end

---@param node Node
function Explorer:dir_up(node)
if not node or node.name == ".." then
change_dir.fn("..")
else
local cwd = core.get_cwd()
if cwd == nil then
return
end

local newdir = vim.fn.fnamemodify(utils.path_remove_trailing(cwd), ":h")
change_dir.fn(newdir)
find_file.fn(node.absolute_path)
end
end

---Api.tree.get_nodes
---@return nvim_tree.api.Node
function Explorer:get_nodes()
Expand Down
Loading