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.

Disable copilot for feedback and lsp log editors

Kirill Bulatov253c8dbe8ea6
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 0bfd6afa3b2..56c5be0fbd6 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -604,6 +604,7 @@ pub struct Editor {
gutter_width: Pixels,
style: Option<EditorStyle>,
editor_actions: Vec<Box<dyn Fn(&mut ViewContext<Self>)>>,
+ show_copilot_suggestions: bool,
}
pub struct EditorSnapshot {
@@ -1804,6 +1805,7 @@ impl Editor {
gutter_width: Default::default(),
style: None,
editor_actions: Default::default(),
+ show_copilot_suggestions: mode == EditorMode::Full,
_subscriptions: vec![
cx.observe(&buffer, Self::on_buffer_changed),
cx.subscribe(&buffer, Self::on_buffer_event),
@@ -2066,6 +2068,10 @@ impl Editor {
self.read_only = read_only;
}
+ pub fn set_show_copilot_suggestions(&mut self, show_copilot_suggestions: bool) {
+ self.show_copilot_suggestions = show_copilot_suggestions;
+ }
+
fn selections_did_change(
&mut self,
local: bool,
@@ -3976,7 +3982,7 @@ impl Editor {
cx: &mut ViewContext<Self>,
) -> Option<()> {
let copilot = Copilot::global(cx)?;
- if self.mode != EditorMode::Full || !copilot.read(cx).status().is_authorized() {
+ if !self.show_copilot_suggestions || !copilot.read(cx).status().is_authorized() {
self.clear_copilot_suggestions(cx);
return None;
}
@@ -4036,7 +4042,7 @@ impl Editor {
cx: &mut ViewContext<Self>,
) -> Option<()> {
let copilot = Copilot::global(cx)?;
- if self.mode != EditorMode::Full || !copilot.read(cx).status().is_authorized() {
+ if !self.show_copilot_suggestions || !copilot.read(cx).status().is_authorized() {
return None;
}
@@ -4161,7 +4167,8 @@ impl Editor {
let file = snapshot.file_at(location);
let language = snapshot.language_at(location);
let settings = all_language_settings(file, cx);
- settings.copilot_enabled(language, file.map(|f| f.path().as_ref()))
+ self.show_copilot_suggestions
+ && settings.copilot_enabled(language, file.map(|f| f.path().as_ref()))
}
fn has_active_copilot_suggestion(&self, cx: &AppContext) -> bool {
diff --git a/crates/feedback/src/feedback_modal.rs b/crates/feedback/src/feedback_modal.rs
index 2444a8e9485..38e06376cb6 100644
--- a/crates/feedback/src/feedback_modal.rs
+++ b/crates/feedback/src/feedback_modal.rs
@@ -186,6 +186,7 @@ impl FeedbackModal {
cx,
);
editor.set_show_gutter(false, cx);
+ editor.set_show_copilot_suggestions(false);
editor.set_vertical_scroll_margin(5, cx);
editor
});
diff --git a/crates/language_tools/src/lsp_log.rs b/crates/language_tools/src/lsp_log.rs
index e3718267582..62aead0857c 100644
--- a/crates/language_tools/src/lsp_log.rs
+++ b/crates/language_tools/src/lsp_log.rs
@@ -449,6 +449,7 @@ impl LspLogView {
editor.set_text(log_contents, cx);
editor.move_to_end(&MoveToEnd, cx);
editor.set_read_only(true);
+ editor.set_show_copilot_suggestions(false);
editor
});
let editor_subscription = cx.subscribe(