@@ -9,6 +9,7 @@ local keymap = require("nvim-tree.keymap")
9
9
local notify = require (" nvim-tree.notify" )
10
10
11
11
local DirectoryNode = require (" nvim-tree.node.directory" )
12
+ local FileLinkNode = require (" nvim-tree.node.file-link" )
12
13
local RootNode = require (" nvim-tree.node.root" )
13
14
14
15
local Api = {
@@ -206,10 +207,8 @@ Api.fs.copy.relative_path = wrap_node(wrap_explorer_member("clipboard", "copy_pa
206
207
--- @param mode string
207
208
--- @param node Node
208
209
local 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
213
212
actions .node .open_file .fn (mode , path )
214
213
end
215
214
@@ -219,10 +218,13 @@ end
219
218
local function open_or_expand_or_dir_up (mode , toggle_group )
220
219
--- @param node Node
221
220
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
223
225
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 )
226
228
elseif not toggle_group then
227
229
edit (mode , node )
228
230
end
0 commit comments