diff --git a/server/continuedev/models/filesystem.py b/server/continuedev/models/filesystem.py index 27244c4b3..59b35f481 100644 --- a/server/continuedev/models/filesystem.py +++ b/server/continuedev/models/filesystem.py @@ -43,6 +43,9 @@ class RangeInFileWithContents(RangeInFile): def __hash__(self): return hash((self.filepath, self.range, self.contents)) + def to_range_in_file(self) -> RangeInFile: + return RangeInFile(filepath=self.filepath, range=self.range) + def union(self, other: "RangeInFileWithContents") -> "RangeInFileWithContents": assert self.filepath == other.filepath # Use a placeholder variable for self and swap it with other if other comes before self diff --git a/server/continuedev/plugins/context_providers/highlighted_code.py b/server/continuedev/plugins/context_providers/highlighted_code.py index 7a9b0cd4b..c2c21baa7 100644 --- a/server/continuedev/plugins/context_providers/highlighted_code.py +++ b/server/continuedev/plugins/context_providers/highlighted_code.py @@ -1,3 +1,4 @@ +import asyncio import os from typing import Any, Dict, List, Optional @@ -78,6 +79,13 @@ class HighlightedCodeContextProvider(ContextProvider): ): ranges = [fallback_item] + fresh_contents_tasks = [ + self.sdk.ide.readRangeInFile(r.rif.to_range_in_file()) for r in ranges + ] + fresh_contents = await asyncio.gather(*fresh_contents_tasks) + for i in range(len(ranges)): + ranges[i].rif.contents = fresh_contents[i] + return [ ChatMessage( role="user",