Avoid interpolating Copilot suggestion if cursor excerpt differs

This commit is contained in:
Antonio Scandurra 2023-04-13 10:36:21 +02:00
parent a85c2d71ad
commit 495c7acadf
2 changed files with 106 additions and 1 deletions

View file

@ -1040,7 +1040,8 @@ impl CopilotState {
let completion = self.completions.get(self.active_completion_index)?;
let excerpt_id = self.excerpt_id?;
let completion_buffer = buffer.buffer_for_excerpt(excerpt_id)?;
if !completion.range.start.is_valid(completion_buffer)
if excerpt_id != cursor.excerpt_id
|| !completion.range.start.is_valid(completion_buffer)
|| !completion.range.end.is_valid(completion_buffer)
{
return None;