tree, dont_show_children_nodes, number of direct children

This commit is contained in:
Amber 2024-01-25 08:46:28 +01:00
parent c2c0f3ec3c
commit f6424891b9
6 changed files with 11 additions and 4 deletions

Binary file not shown.

View File

@ -19,7 +19,7 @@ class NerdTree():
else:
self.json_tree = {}
def sort_directory_first(self, startpath):
def sort_directories_first(self, startpath):
files = []
dirs = []
@ -42,7 +42,7 @@ class NerdTree():
dirfirst = self.opts['list_dir_first'] if self.opts.get('list_dir_first') is not None else False
if dirfirst:
return self.sort_directory_first(startpath)
return self.sort_directories_first(startpath)
return os.listdir(startpath)
@ -125,6 +125,9 @@ class NerdTree():
else:
nerd_tree_txt = rootnode_name
if rootnode.get('nchildren') is not None:
nerd_tree_txt += ' (%s▾)' % rootnode['nchildren']
items = rootnode.get('children') or []
for n, item in enumerate(items):

View File

@ -70,6 +70,7 @@ class NerdTreeFind(NerdTree):
if dont_show_children_nodes:
for result in results:
result['nchildren'] = len(result['children'])
result['children'] = []
tree_struct = {}

View File

@ -37,6 +37,11 @@ def produce_treeline(prec_seps, lsep):
else:
item_name = item['name']
tomount = sep + item_name
# if item.get('type') == 'd':
# if item.get('nchildren') is not None:
# tomount += '(%s)' % (item['nchildren'],)
tree_line = mount_str_at(tree_line, level2indent(level_n), tomount)
return tree_line.rstrip()
@ -45,8 +50,6 @@ def nerd_tree_sort_dirfirst(startpath):
files = []
dirs = []
for item in os.listdir(startpath):
if os.path.isdir(startpath + item):
dirs.append(item)