Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Make applying of additional completion edits go through the CompletionProvider
Max Brunsfeld8fb0270b4a05
diff --git a/crates/collab_ui/src/chat_panel/message_editor.rs b/crates/collab_ui/src/chat_panel/message_editor.rsindex c19d19085c9..48d3f31aa90 100644--- a/crates/collab_ui/src/chat_panel/message_editor.rs+++ b/crates/collab_ui/src/chat_panel/message_editor.rs@@ -61,6 +61,16 @@ impl CompletionProvider for MessageEditorCompletionProvider {) -> Task<anyhow::Result<bool>> {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 {diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 55090d75d95..47e4acdedf7 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -3285,15 +3285,13 @@ impl Editor {this.refresh_copilot_suggestions(true, cx);});- let project = self.project.clone()?;- let apply_edits = project.update(cx, |project, cx| {- project.apply_additional_edits_for_completion(- buffer_handle,- completion.clone(),- true,- cx,- )- });+ let provider = self.completion_provider.as_ref()?;+ let apply_edits = provider.apply_additional_edits_for_completion(+ buffer_handle,+ completion.clone(),+ true,+ cx,+ );Some(cx.foreground_executor().spawn(async move {apply_edits.await?;Ok(())@@ -8912,12 +8910,21 @@ pub trait CompletionProvider {buffer_position: text::Anchor,cx: &mut ViewContext<Editor>,) -> Task<Result<Vec<Completion>>>;+fn resolve_completions(&self,completion_indices: Vec<usize>,completions: Arc<RwLock<Box<[Completion]>>>,cx: &mut ViewContext<Editor>,) -> 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> {@@ -8942,6 +8949,18 @@ impl CompletionProvider for Model<Project> {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(