File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ local rename_file = require("nvim-tree.actions.fs.rename-file")
88local trash = require (" nvim-tree.actions.fs.trash" )
99local utils = require (" nvim-tree.utils" )
1010
11+ local DirectoryNode = require " nvim-tree.node.directory"
12+
1113--- @class Marks
1214--- @field config table hydrated user opts.filters
1315--- @field private explorer Explorer
@@ -152,7 +154,7 @@ function Marks:bulk_move()
152154 local node_at_cursor = lib .get_node_at_cursor ()
153155 local default_path = core .get_cwd ()
154156
155- if node_at_cursor and node_at_cursor . type == " directory " then
157+ if node_at_cursor and node_at_cursor : is ( DirectoryNode ) then
156158 default_path = node_at_cursor .absolute_path
157159 elseif node_at_cursor and node_at_cursor .parent then
158160 default_path = node_at_cursor .parent .absolute_path
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ local Watcher = require("nvim-tree.watcher")
55
66local M = {}
77
8+ --- TODO merge #2922 and pass just stat, as stat.type from lstat is correct
9+
810--- Factory function to create the appropriate Node
911--- @param explorer Explorer
1012--- @param parent Node
Original file line number Diff line number Diff line change @@ -38,6 +38,23 @@ function BaseNode:destroy()
3838 end
3939end
4040
41+ --- From plenary
42+ --- Checks if the object is an instance
43+ --- This will start with the lowest class and loop over all the superclasses.
44+ --- @param self BaseNode
45+ --- @param T BaseNode
46+ --- @return boolean
47+ function BaseNode :is (T )
48+ local mt = getmetatable (self )
49+ while mt do
50+ if mt == T then
51+ return true
52+ end
53+ mt = getmetatable (mt )
54+ end
55+ return false
56+ end
57+
4158--- @return boolean
4259function BaseNode :has_one_child_folder ()
4360 return # self .nodes == 1 and self .nodes [1 ].nodes and vim .loop .fs_access (self .nodes [1 ].absolute_path , " R" ) or false
You can’t perform that action at this time.
0 commit comments