dont_show_children, aggregate data

This commit is contained in:
Amber
2024-01-30 14:24:21 +01:00
parent 60ccd874df
commit de88767812
4 changed files with 47 additions and 17 deletions

View File

@ -19,7 +19,7 @@ class NerdTreeFind(NerdTree):
def find_node_recursively(self, node):
if node['name'] == self.item_name:
node_copy = node.copy()
node_copy.update({'color_formatter' : YELLOW})
node_copy.update({'color_formatter' : YELLOW, 'found' : 1})
self.results.append(node_copy)
children = node.get('children') or []
@ -30,7 +30,7 @@ class NerdTreeFind(NerdTree):
else:
if item_child['name'] == self.item_name:
item_child_copy = item_child.copy()
item_child_copy.update({'color_formatter' : YELLOW})
item_child_copy.update({'color_formatter' : YELLOW, 'found' : 1})
self.results.append(item_child_copy)
def find_node(self):
@ -64,16 +64,19 @@ class NerdTreeFind(NerdTree):
'''
results = self.find_node()
dont_show_children_nodes = self.find_opts['dont_show_children_nodes'] if self.find_opts.get('dont_show_children_nodes') is not None else False
## remove from this level the option
if not results:
return {}
if dont_show_children_nodes:
for result in results:
children = result.get('children') or []
result['nchildren'] = len(children)
result['children'] = []
# if dont_show_children_nodes:
# for result in results:
# children = result.get('children') or []
# result['nchildren'] = len(children)
# result['children'] = []
dont_show_children_nodes = self.find_opts['dont_show_children_nodes'] if self.find_opts.get('dont_show_children_nodes') is not None else False
self.opts['dont_show_children_nodes'] = dont_show_children_nodes
tree_struct = {}
@ -104,6 +107,7 @@ class NerdTreeFind(NerdTree):
if not islastpath: children.append(pcopy)
else : children.append(node)
self.compute_aggregate_recursively(tree_struct)
return tree_struct
def reset(self, new_item_name, new_opts):