Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Don't update active completion for editors that are not focused (#9904)

Antonio Scandurrac33ee52046ef
diff --git a/crates/copilot_ui/src/copilot_completion_provider.rs b/crates/copilot_ui/src/copilot_completion_provider.rs
index c50f8aa8774..ac9f2511fea 100644
--- a/crates/copilot_ui/src/copilot_completion_provider.rs
+++ b/crates/copilot_ui/src/copilot_completion_provider.rs
@@ -764,6 +764,7 @@ mod tests {
multibuffer
});
let editor = cx.add_window(|cx| Editor::for_multibuffer(multibuffer, None, cx));
+ editor.update(cx, |editor, cx| editor.focus(cx)).unwrap();
let copilot_provider = cx.new_model(|_| CopilotCompletionProvider::new(copilot));
editor
.update(cx, |editor, cx| {
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index ff00acb0bb8..510dcc8ee58 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -1676,7 +1676,9 @@ impl Editor {
) {
self.inline_completion_provider = Some(RegisteredInlineCompletionProvider {
_subscription: cx.observe(&provider, |this, _, cx| {
- this.update_visible_inline_completion(cx);
+ if this.focus_handle.is_focused(cx) {
+ this.update_visible_inline_completion(cx);
+ }
}),
provider: Arc::new(provider),
});