Skip to content

Commit cd89c75

Browse files
committed
last_group_node is DirectoryNode only
1 parent dcaf852 commit cd89c75

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

lua/nvim-tree/api.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ local keymap = require("nvim-tree.keymap")
1010
local notify = require("nvim-tree.notify")
1111

1212
local DirectoryNode = require("nvim-tree.node.directory")
13+
local RootNode = require("nvim-tree.node.root")
1314

1415
local Api = {
1516
tree = {},
@@ -137,9 +138,9 @@ Api.tree.change_root = wrap(function(...)
137138
end)
138139

139140
Api.tree.change_root_to_node = wrap_node(function(node)
140-
if node.name == ".." then
141+
if node.name == ".." or node:is(RootNode) then
141142
actions.root.change_dir.fn("..")
142-
elseif node.nodes ~= nil then
143+
elseif node:is(DirectoryNode) then
143144
actions.root.change_dir.fn(node:last_group_node().absolute_path)
144145
end
145146
end)

lua/nvim-tree/node/init.lua

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ function Node:is_dotfile()
7070
return false
7171
end
7272

73-
---Return self, should only be called on a DirectoryNode
74-
---TODO #2886 remove method or leave in place, warn if practical and non too intrusive
75-
---@return Node
76-
function Node:last_group_node()
77-
error(string.format("\nNode:last_group_node called for '%s'", self.absolute_path))
78-
return self
79-
end
80-
8173
---@param project table?
8274
---@param root string?
8375
function Node:update_parent_statuses(project, root)

0 commit comments

Comments
 (0)