add include path
This commit is contained in:
		| @@ -15,6 +15,8 @@ cmd_parser.add_argument("-s", "--show-children-nodes", action="store_true") | ||||
| ## more than one occurrencies of -e option are appended in a list | ||||
| cmd_parser.add_argument("-e", "--exclude", action="append") | ||||
|  | ||||
| cmd_parser.add_argument("-i", "--include", action="append") | ||||
|  | ||||
| # start the command line parsing | ||||
| cmd_args = cmd_parser.parse_args() | ||||
|  | ||||
|   | ||||
| @@ -82,6 +82,18 @@ class NerdTreeFind(NerdTree): | ||||
|     if not results: | ||||
|       return {} | ||||
|  | ||||
|     ## filter results | ||||
|     items_to_include= self.find_opts['items_to_include'] if self.find_opts.get('items_to_include') is not None else [] | ||||
|     if items_to_include: | ||||
|       filtered_results = [] | ||||
|       items_to_include_set = set(items_to_include) | ||||
|       for res in results: | ||||
|         pathset = set(path['name'] for path in res['path']) | ||||
|         if not items_to_include_set.intersection(pathset):  | ||||
|           continue | ||||
|         filtered_results.append(res.copy()) | ||||
|       results = filtered_results | ||||
|  | ||||
|     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 | ||||
|      | ||||
| @@ -115,7 +127,6 @@ class NerdTreeFind(NerdTree): | ||||
|         if not islastpath:   children.append(pcopy) | ||||
|         else             :   children.append(node) | ||||
|  | ||||
|     # key size is lost in preceding code!!!!!!!!!!!! | ||||
|     self.compute_aggregate_recursively(tree_struct) | ||||
|     return tree_struct | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user