From 7b685ce0892145c8b7c5b3b5338a21447a46d71a Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 24 May 2023 14:31:32 -0700 Subject: [PATCH] use the tree to render the plain file list --- aider/ctags.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/aider/ctags.py b/aider/ctags.py index 30de11320..9c17a6b51 100644 --- a/aider/ctags.py +++ b/aider/ctags.py @@ -24,6 +24,10 @@ def get_tags_map(filenames, root_dname=None): if not tags: return + return to_tree(tags) + + +def to_tree(tags): tags = sorted(tags) output = "" @@ -49,7 +53,11 @@ def get_tags_map(filenames, root_dname=None): def split_path(path, root_dname): path = os.path.relpath(path, root_dname) - path_components = path.split(os.sep) + return fname_to_components(path, True) + + +def fname_to_components(fname, with_colon): + path_components = os.path.split(fname) res = [pc + os.sep for pc in path_components[:-1]] res.append(path_components[-1] + ":") return res @@ -141,8 +149,13 @@ class RepoMap: return files_listing, ctags_msg def get_simple_files_map(self, other_files): - files_listing = "\n".join(self.get_rel_fname(ofn) for ofn in sorted(other_files)) - return files_listing + fnames = [] + for fname in other_files: + fname = self.get_rel_fname(fname) + fname = fname_to_components(fname, False) + fnames.append(fname) + + return to_tree(fnames) def token_count(self, string): return len(self.tokenizer.encode(string))