File tree 3 files changed +22
-1
lines changed
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")
8
8
local trash = require (" nvim-tree.actions.fs.trash" )
9
9
local utils = require (" nvim-tree.utils" )
10
10
11
+ local DirectoryNode = require " nvim-tree.node.directory"
12
+
11
13
--- @class Marks
12
14
--- @field config table hydrated user opts.filters
13
15
--- @field private explorer Explorer
@@ -152,7 +154,7 @@ function Marks:bulk_move()
152
154
local node_at_cursor = lib .get_node_at_cursor ()
153
155
local default_path = core .get_cwd ()
154
156
155
- if node_at_cursor and node_at_cursor . type == " directory " then
157
+ if node_at_cursor and node_at_cursor : is ( DirectoryNode ) then
156
158
default_path = node_at_cursor .absolute_path
157
159
elseif node_at_cursor and node_at_cursor .parent then
158
160
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")
5
5
6
6
local M = {}
7
7
8
+ --- TODO merge #2922 and pass just stat, as stat.type from lstat is correct
9
+
8
10
--- Factory function to create the appropriate Node
9
11
--- @param explorer Explorer
10
12
--- @param parent Node
Original file line number Diff line number Diff line change @@ -38,6 +38,23 @@ function BaseNode:destroy()
38
38
end
39
39
end
40
40
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
+
41
58
--- @return boolean
42
59
function BaseNode :has_one_child_folder ()
43
60
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