From d37892121e27e18d85544d849354c6a755b0414c Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 18 Jul 2023 19:37:17 -0700 Subject: filepath disambiguation fix --- continuedev/src/continuedev/core/autopilot.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'continuedev/src') diff --git a/continuedev/src/continuedev/core/autopilot.py b/continuedev/src/continuedev/core/autopilot.py index 4e177ac9..afbfc7ed 100644 --- a/continuedev/src/continuedev/core/autopilot.py +++ b/continuedev/src/continuedev/core/autopilot.py @@ -100,9 +100,14 @@ class Autopilot(ContinueBaseModel): self.continue_sdk.update_default_model(model) async def clear_history(self): + # Reset history self.history = History.from_empty() self._main_user_input_queue = [] self._active = False + + # Also remove all context + self._highlighted_ranges = [] + await self.update_subscribers() def on_update(self, callback: Coroutine["FullState", None, None]): @@ -168,19 +173,22 @@ class Autopilot(ContinueBaseModel): def _disambiguate_highlighted_ranges(self): """If any files have the same name, also display their folder name""" - name_counts = {} + name_status: Dict[str, set] = { + } # basename -> set of full paths with that basename for rif in self._highlighted_ranges: - if rif.display_name in name_counts: - name_counts[rif.display_name] += 1 + basename = os.path.basename(rif.range.filepath) + if basename in name_status: + name_status[basename].add(rif.range.filepath) else: - name_counts[rif.display_name] = 1 + name_status[basename] = {rif.range.filepath} for rif in self._highlighted_ranges: - if name_counts[rif.display_name] > 1: + basename = os.path.basename(rif.range.filepath) + if len(name_status[basename]) > 1: rif.display_name = os.path.join( - os.path.basename(os.path.dirname(rif.range.filepath)), rif.display_name) + os.path.basename(os.path.dirname(rif.range.filepath)), basename) else: - rif.display_name = os.path.basename(rif.range.filepath) + rif.display_name = basename async def handle_highlighted_code(self, range_in_files: List[RangeInFileWithContents]): # Filter out rifs from ~/.continue/diffs folder -- cgit v1.2.3-70-g09d2