diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-07-17 12:24:22 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-07-17 12:24:22 -0700 |
commit | e65a15f50d226acd802ffc580306e1477394ffe0 (patch) | |
tree | 5c138c73d33e8044e6d03aee35952c9efc6713dd /continuedev | |
parent | 5236e6287e9bacb15a285a03a27f6919d87f9626 (diff) | |
download | sncontinue-e65a15f50d226acd802ffc580306e1477394ffe0.tar.gz sncontinue-e65a15f50d226acd802ffc580306e1477394ffe0.tar.bz2 sncontinue-e65a15f50d226acd802ffc580306e1477394ffe0.zip |
disambiguate highlighted ranges with dirname
Diffstat (limited to 'continuedev')
-rw-r--r-- | continuedev/src/continuedev/core/autopilot.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/continuedev/src/continuedev/core/autopilot.py b/continuedev/src/continuedev/core/autopilot.py index 0696c360..fb8da2e8 100644 --- a/continuedev/src/continuedev/core/autopilot.py +++ b/continuedev/src/continuedev/core/autopilot.py @@ -166,6 +166,22 @@ class Autopilot(ContinueBaseModel): if not any(map(lambda x: x.editing, self._highlighted_ranges)): self._highlighted_ranges[0].editing = True + def _disambiguate_highlighted_ranges(self): + """If any files have the same name, also display their folder name""" + name_counts = {} + for rif in self._highlighted_ranges: + if rif.display_name in name_counts: + name_counts[rif.display_name] += 1 + else: + name_counts[rif.display_name] = 1 + + for rif in self._highlighted_ranges: + if name_counts[rif.display_name] > 1: + rif.display_name = os.path.join( + os.path.basename(os.path.dirname(rif.range.filepath)), rif.display_name) + else: + rif.display_name = os.path.basename(rif.range.filepath) + async def handle_highlighted_code(self, range_in_files: List[RangeInFileWithContents]): # Filter out rifs from ~/.continue/diffs folder range_in_files = [ @@ -211,6 +227,7 @@ class Autopilot(ContinueBaseModel): ) for rif in range_in_files] self._make_sure_is_editing_range() + self._disambiguate_highlighted_ranges() await self.update_subscribers() |