@@ -216,6 +216,7 @@ create_nodes = function(source_items, state, level)
216216 extra = item .extra ,
217217 is_nested = item .is_nested ,
218218 skip_node = item .skip_node ,
219+ is_empty_with_hidden_root = item .is_empty_with_hidden_root ,
219220 -- TODO: The below properties are not universal and should not be here.
220221 -- Maybe they should be moved to the "extra" field?
221222 is_link = item .is_link ,
315316
316317local prepare_node = function (item , state )
317318 if item .skip_node then
318- return nil
319+ if item .is_empty_with_hidden_root then
320+ local line = NuiLine ()
321+ line :append (" (empty folder)" , highlights .MESSAGE )
322+ return line
323+ else
324+ return nil
325+ end
319326 end
320327 -- pre_render is used to calculate the longest node width
321328 -- without actually rendering the node.
@@ -1074,7 +1081,6 @@ M.show_nodes = function(sourceItems, state, parentId, callback)
10741081 -- local id = string.format("show_nodes %s:%s [%s]", state.name, state.force_float, state.tabnr)
10751082 -- utils.debounce(id, function()
10761083 events .fire_event (events .BEFORE_RENDER , state )
1077- local is_empty_with_hidden_root = false
10781084 state .longest_width_exact = 0
10791085 local parent
10801086 local level = 0
@@ -1093,10 +1099,8 @@ M.show_nodes = function(sourceItems, state, parentId, callback)
10931099 if config .hide_root_node then
10941100 if not parentId then
10951101 sourceItems [1 ].skip_node = true
1096- if sourceItems [1 ].children and # sourceItems [1 ].children > 0 then
1097- is_empty_with_hidden_root = false
1098- else
1099- is_empty_with_hidden_root = true
1102+ if not (sourceItems [1 ].children and # sourceItems [1 ].children > 0 ) then
1103+ sourceItems [1 ].is_empty_with_hidden_root = true
11001104 end
11011105 end
11021106 if not config .retain_hidden_root_indent then
@@ -1163,17 +1167,6 @@ M.show_nodes = function(sourceItems, state, parentId, callback)
11631167 if sourceItems then
11641168 -- normal path
11651169 local nodes = create_nodes (sourceItems , state , level )
1166- if is_empty_with_hidden_root then
1167- local nodeData = {
1168- id = state .path .. " _empty_message" ,
1169- name = " (empty folder)" ,
1170- type = " message" ,
1171- level = 0 ,
1172- is_last_child = true ,
1173- }
1174- local node = NuiTree .Node (nodeData , {})
1175- table.insert (nodes , node )
1176- end
11771170 draw (nodes , state , parentId )
11781171 else
11791172 -- this was a force grouping of a lazy loaded folder
0 commit comments