@@ -3,11 +3,10 @@ local log = require "nvim-tree.log"
33local notify = require " nvim-tree.notify"
44local utils = require " nvim-tree.utils"
55local view = require " nvim-tree.view"
6+ local node_factory = require " nvim-tree.node.factory"
67
78local BaseNode = require " nvim-tree.node"
89local DirectoryNode = require " nvim-tree.node.directory"
9- local FileNode = require " nvim-tree.node.file"
10- local LinkNode = require " nvim-tree.node.link"
1110local Watcher = require " nvim-tree.watcher"
1211
1312local Iterator = require " nvim-tree.iterators.node-iterator"
@@ -150,17 +149,7 @@ function Explorer:reload(node, git_status)
150149 end
151150
152151 if not nodes_by_path [abs ] then
153- local new_child = nil
154- if type == " directory" and vim .loop .fs_access (abs , " R" ) and Watcher .is_fs_event_capable (abs ) then
155- new_child = DirectoryNode :new (self , node , abs , name , stat )
156- elseif type == " file" then
157- new_child = FileNode :new (self , node , abs , name , stat )
158- elseif type == " link" then
159- local link = LinkNode :new (self , node , abs , name , stat )
160- if link .link_to ~= nil then
161- new_child = link
162- end
163- end
152+ local new_child = node_factory .create_node (self , node , abs , stat , name )
164153 if new_child then
165154 table.insert (node .nodes , new_child )
166155 nodes_by_path [abs ] = new_child
@@ -351,7 +340,7 @@ function Explorer:populate_children(handle, cwd, node, git_status, parent)
351340 })
352341
353342 while true do
354- local name , t = vim .loop .fs_scandir_next (handle )
343+ local name , _ = vim .loop .fs_scandir_next (handle )
355344 if not name then
356345 break
357346 end
@@ -365,17 +354,7 @@ function Explorer:populate_children(handle, cwd, node, git_status, parent)
365354 local stat = vim .loop .fs_stat (abs )
366355 local filter_reason = parent .filters :should_filter_as_reason (abs , stat , filter_status )
367356 if filter_reason == FILTER_REASON .none and not nodes_by_path [abs ] then
368- local child = nil
369- if t == " directory" and vim .loop .fs_access (abs , " R" ) then
370- child = DirectoryNode :new (self , node , abs , name , stat )
371- elseif t == " file" then
372- child = FileNode :new (self , node , abs , name , stat )
373- elseif t == " link" then
374- local link = LinkNode :new (self , node , abs , name , stat )
375- if link .link_to ~= nil then
376- child = link
377- end
378- end
357+ local child = node_factory .create_node (self , node , abs , stat , name )
379358 if child then
380359 table.insert (node .nodes , child )
381360 nodes_by_path [child .absolute_path ] = true
0 commit comments