@@ -9,6 +9,7 @@ local keymap = require("nvim-tree.keymap")
99local notify = require (" nvim-tree.notify" )
1010
1111local DirectoryNode = require (" nvim-tree.node.directory" )
12+ local FileLinkNode = require (" nvim-tree.node.file-link" )
1213local RootNode = require (" nvim-tree.node.root" )
1314
1415local Api = {
@@ -206,10 +207,8 @@ Api.fs.copy.relative_path = wrap_node(wrap_explorer_member("clipboard", "copy_pa
206207--- @param mode string
207208--- @param node Node
208209local function edit (mode , node )
209- local path = node .absolute_path
210- if node .link_to and not node .nodes then
211- path = node .link_to
212- end
210+ local file_link = node :as (FileLinkNode )
211+ local path = file_link and file_link .link_to or node .absolute_path
213212 actions .node .open_file .fn (mode , path )
214213end
215214
@@ -219,10 +218,13 @@ end
219218local function open_or_expand_or_dir_up (mode , toggle_group )
220219 --- @param node Node
221220 return function (node )
222- if node .name == " .." then
221+ local root = node :as (RootNode )
222+ local dir = node :as (DirectoryNode )
223+
224+ if root or node .name == " .." then
223225 actions .root .change_dir .fn (" .." )
224- elseif node : is ( DirectoryNode ) then
225- node :expand_or_collapse (toggle_group )
226+ elseif dir then
227+ dir :expand_or_collapse (toggle_group )
226228 elseif not toggle_group then
227229 edit (mode , node )
228230 end
0 commit comments