🧑‍💻 refresh contents of highlighted ranges

This commit is contained in:
Nate Sesti 2023-10-23 11:30:17 -07:00
parent c6a51f6f45
commit 8fbbabe836
2 changed files with 11 additions and 0 deletions

View file

@ -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

View file

@ -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",