Disable copilot for feedback and lsp log editors (#4048)

LSP log editor caused recursive flood of messages, and feedback editor
is better with people writing their own feedback.

Release Notes:

- Fixed hanging due to excessive logs when browsing Copilot LSP logs
This commit is contained in:
Kirill Bulatov 2024-01-15 15:59:27 +02:00 committed by GitHub
commit fc294ce0b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View file

@ -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 {

View file

@ -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
});

View file

@ -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(