Fix prefix/suffix calculation when determining copilot suggestion

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
Antonio Scandurra 2023-03-31 18:03:38 +02:00
parent b588ba1435
commit 5f579a4287
3 changed files with 30 additions and 20 deletions

View file

@ -1579,6 +1579,14 @@ impl BufferSnapshot {
self.text_for_range(range).flat_map(str::chars)
}
pub fn reversed_chars_for_range<T: ToOffset>(
&self,
range: Range<T>,
) -> impl Iterator<Item = char> + '_ {
self.reversed_chunks_in_range(range)
.flat_map(|chunk| chunk.chars().rev())
}
pub fn contains_str_at<T>(&self, position: T, needle: &str) -> bool
where
T: ToOffset,