Skip to content
Merged
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
17 changes: 12 additions & 5 deletions lua/nvim-tree/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local keymap = require("nvim-tree.keymap")
local notify = require("nvim-tree.notify")

local DirectoryNode = require("nvim-tree.node.directory")
local FileNode = require("nvim-tree.node.file")
local FileLinkNode = require("nvim-tree.node.file-link")
local RootNode = require("nvim-tree.node.root")
local UserDecorator = require("nvim-tree.renderer.decorator.user")
Expand Down Expand Up @@ -160,11 +161,17 @@ end)
Api.tree.change_root_to_node = wrap_node(function(node)
if node.name == ".." or node:is(RootNode) then
actions.root.change_dir.fn("..")
else
node = node:as(DirectoryNode)
if node then
actions.root.change_dir.fn(node:last_group_node().absolute_path)
end
return
end

if node:is(FileNode) and node.parent ~= nil then
actions.root.change_dir.fn(node.parent:last_group_node().absolute_path)
return
end

if node:is(DirectoryNode) then
actions.root.change_dir.fn(node:last_group_node().absolute_path)
return
end
end)

Expand Down
Loading