@@ -3,11 +3,10 @@ local log = require "nvim-tree.log"
3
3
local notify = require " nvim-tree.notify"
4
4
local utils = require " nvim-tree.utils"
5
5
local view = require " nvim-tree.view"
6
+ local node_factory = require " nvim-tree.node.factory"
6
7
7
8
local BaseNode = require " nvim-tree.node"
8
9
local DirectoryNode = require " nvim-tree.node.directory"
9
- local FileNode = require " nvim-tree.node.file"
10
- local LinkNode = require " nvim-tree.node.link"
11
10
local Watcher = require " nvim-tree.watcher"
12
11
13
12
local Iterator = require " nvim-tree.iterators.node-iterator"
@@ -147,17 +146,7 @@ function Explorer:reload(node, git_status)
147
146
end
148
147
149
148
if not nodes_by_path [abs ] then
150
- local new_child = nil
151
- if t == " directory" and vim .loop .fs_access (abs , " R" ) and Watcher .is_fs_event_capable (abs ) then
152
- new_child = DirectoryNode :new (self , node , abs , name , stat )
153
- elseif t == " file" then
154
- new_child = FileNode :new (self , node , abs , name , stat )
155
- elseif t == " link" then
156
- local link = LinkNode :new (self , node , abs , name , stat )
157
- if link .link_to ~= nil then
158
- new_child = link
159
- end
160
- end
149
+ local new_child = node_factory .create_node (self , node , abs , stat , name )
161
150
if new_child then
162
151
table.insert (node .nodes , new_child )
163
152
nodes_by_path [abs ] = new_child
@@ -348,7 +337,7 @@ function Explorer:populate_children(handle, cwd, node, git_status, parent)
348
337
})
349
338
350
339
while true do
351
- local name , t = vim .loop .fs_scandir_next (handle )
340
+ local name , _ = vim .loop .fs_scandir_next (handle )
352
341
if not name then
353
342
break
354
343
end
@@ -362,17 +351,7 @@ function Explorer:populate_children(handle, cwd, node, git_status, parent)
362
351
local stat = vim .loop .fs_stat (abs )
363
352
local filter_reason = parent .filters :should_filter_as_reason (abs , stat , filter_status )
364
353
if filter_reason == FILTER_REASON .none and not nodes_by_path [abs ] then
365
- local child = nil
366
- if t == " directory" and vim .loop .fs_access (abs , " R" ) then
367
- child = DirectoryNode :new (self , node , abs , name , stat )
368
- elseif t == " file" then
369
- child = FileNode :new (self , node , abs , name , stat )
370
- elseif t == " link" then
371
- local link = LinkNode :new (self , node , abs , name , stat )
372
- if link .link_to ~= nil then
373
- child = link
374
- end
375
- end
354
+ local child = node_factory .create_node (self , node , abs , stat , name )
376
355
if child then
377
356
table.insert (node .nodes , child )
378
357
nodes_by_path [child .absolute_path ] = true
0 commit comments