Make applying of additional completion edits go through the CompletionProvider
This commit is contained in:
parent
c8adde32de
commit
8fb0270b4a
2 changed files with 38 additions and 9 deletions
|
@ -61,6 +61,16 @@ impl CompletionProvider for MessageEditorCompletionProvider {
|
||||||
) -> Task<anyhow::Result<bool>> {
|
) -> Task<anyhow::Result<bool>> {
|
||||||
Task::ready(Ok(false))
|
Task::ready(Ok(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn apply_additional_edits_for_completion(
|
||||||
|
&self,
|
||||||
|
_buffer: Model<Buffer>,
|
||||||
|
_completion: Completion,
|
||||||
|
_push_to_history: bool,
|
||||||
|
_cx: &mut ViewContext<Editor>,
|
||||||
|
) -> Task<Result<Option<language::Transaction>>> {
|
||||||
|
Task::ready(Ok(None))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MessageEditor {
|
impl MessageEditor {
|
||||||
|
|
|
@ -3285,15 +3285,13 @@ impl Editor {
|
||||||
this.refresh_copilot_suggestions(true, cx);
|
this.refresh_copilot_suggestions(true, cx);
|
||||||
});
|
});
|
||||||
|
|
||||||
let project = self.project.clone()?;
|
let provider = self.completion_provider.as_ref()?;
|
||||||
let apply_edits = project.update(cx, |project, cx| {
|
let apply_edits = provider.apply_additional_edits_for_completion(
|
||||||
project.apply_additional_edits_for_completion(
|
|
||||||
buffer_handle,
|
buffer_handle,
|
||||||
completion.clone(),
|
completion.clone(),
|
||||||
true,
|
true,
|
||||||
cx,
|
cx,
|
||||||
)
|
);
|
||||||
});
|
|
||||||
Some(cx.foreground_executor().spawn(async move {
|
Some(cx.foreground_executor().spawn(async move {
|
||||||
apply_edits.await?;
|
apply_edits.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -8912,12 +8910,21 @@ pub trait CompletionProvider {
|
||||||
buffer_position: text::Anchor,
|
buffer_position: text::Anchor,
|
||||||
cx: &mut ViewContext<Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) -> Task<Result<Vec<Completion>>>;
|
) -> Task<Result<Vec<Completion>>>;
|
||||||
|
|
||||||
fn resolve_completions(
|
fn resolve_completions(
|
||||||
&self,
|
&self,
|
||||||
completion_indices: Vec<usize>,
|
completion_indices: Vec<usize>,
|
||||||
completions: Arc<RwLock<Box<[Completion]>>>,
|
completions: Arc<RwLock<Box<[Completion]>>>,
|
||||||
cx: &mut ViewContext<Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) -> Task<Result<bool>>;
|
) -> Task<Result<bool>>;
|
||||||
|
|
||||||
|
fn apply_additional_edits_for_completion(
|
||||||
|
&self,
|
||||||
|
buffer: Model<Buffer>,
|
||||||
|
completion: Completion,
|
||||||
|
push_to_history: bool,
|
||||||
|
cx: &mut ViewContext<Editor>,
|
||||||
|
) -> Task<Result<Option<language::Transaction>>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompletionProvider for Model<Project> {
|
impl CompletionProvider for Model<Project> {
|
||||||
|
@ -8942,6 +8949,18 @@ impl CompletionProvider for Model<Project> {
|
||||||
project.resolve_completions(completion_indices, completions, cx)
|
project.resolve_completions(completion_indices, completions, cx)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn apply_additional_edits_for_completion(
|
||||||
|
&self,
|
||||||
|
buffer: Model<Buffer>,
|
||||||
|
completion: Completion,
|
||||||
|
push_to_history: bool,
|
||||||
|
cx: &mut ViewContext<Editor>,
|
||||||
|
) -> Task<Result<Option<language::Transaction>>> {
|
||||||
|
self.update(cx, |project, cx| {
|
||||||
|
project.apply_additional_edits_for_completion(buffer, completion, push_to_history, cx)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inlay_hint_settings(
|
fn inlay_hint_settings(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue