Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Do not load runnables and diagnostics in git panel (#51270)
Kirill Bulatov2c59990135f2
diff --git a/crates/editor/src/document_colors.rs b/crates/editor/src/document_colors.rsindex 579414c7f91..a38a0527f06 100644--- a/crates/editor/src/document_colors.rs+++ b/crates/editor/src/document_colors.rs@@ -145,7 +145,7 @@ impl Editor {_: &Window,cx: &mut Context<Self>,) {- if !self.mode().is_full() {+ if !self.lsp_data_enabled() {return;}let Some(project) = self.project.as_ref() else {diff --git a/crates/editor/src/document_symbols.rs b/crates/editor/src/document_symbols.rsindex b73c1abbfb9..0228bbd917a 100644--- a/crates/editor/src/document_symbols.rs+++ b/crates/editor/src/document_symbols.rs@@ -147,7 +147,7 @@ impl Editor {for_buffer: Option<BufferId>,cx: &mut Context<Self>,) {- if !self.mode().is_full() {+ if !self.lsp_data_enabled() {return;}let Some(project) = self.project.clone() else {diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex aabf16d2b64..a08ac3bbc46 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -7733,7 +7733,7 @@ impl Editor {#[ztracing::instrument(skip_all)]fn refresh_outline_symbols_at_cursor(&mut self, cx: &mut Context<Editor>) {- if !self.mode.is_full() {+ if !self.lsp_data_enabled() {return;}let cursor = self.selections.newest_anchor().head();@@ -17154,13 +17154,17 @@ impl Editor {}fn refresh_runnables(&mut self, window: &mut Window, cx: &mut Context<Self>) -> Task<()> {- if !EditorSettings::get_global(cx).gutter.runnables || !self.enable_runnables {+ if !self.mode().is_full()+ || !EditorSettings::get_global(cx).gutter.runnables+ || !self.enable_runnables+ {self.clear_tasks();return Task::ready(());}let project = self.project().map(Entity::downgrade);let task_sources = self.lsp_task_sources(cx);let multi_buffer = self.buffer.downgrade();+ let lsp_data_enabled = self.lsp_data_enabled();cx.spawn_in(window, async move |editor, cx| {cx.background_executor().timer(UPDATE_DEBOUNCE).await;let Some(project) = project.and_then(|p| p.upgrade()) else {@@ -17176,20 +17180,27 @@ impl Editor {if hide_runnables {return;}- let new_rows =- cx.background_spawn({+ let new_rows = cx+ .background_spawn({let snapshot = display_snapshot.clone();async move {- Self::fetch_runnable_ranges(&snapshot, Anchor::min()..Anchor::max())+ snapshot+ .buffer_snapshot()+ .runnable_ranges(Anchor::min()..Anchor::max())+ .collect()}})- .await;- let Ok(lsp_tasks) =- cx.update(|_, cx| crate::lsp_tasks(project.clone(), &task_sources, None, cx))- else {- return;+ .await;+ let lsp_tasks = if lsp_data_enabled {+ let Ok(lsp_tasks) =+ cx.update(|_, cx| crate::lsp_tasks(project.clone(), &task_sources, None, cx))+ else {+ return;+ };+ lsp_tasks.await+ } else {+ Vec::new()};- let lsp_tasks = lsp_tasks.await;let Ok(mut lsp_tasks_by_rows) = cx.update(|_, cx| {lsp_tasks@@ -17270,12 +17281,6 @@ impl Editor {.ok();})}- fn fetch_runnable_ranges(- snapshot: &DisplaySnapshot,- range: Range<Anchor>,- ) -> Vec<(Range<MultiBufferOffset>, language::RunnableRange)> {- snapshot.buffer_snapshot().runnable_ranges(range).collect()- }fn runnable_rows(project: Entity<Project>,@@ -19607,7 +19612,7 @@ impl Editor {}pub fn diagnostics_enabled(&self) -> bool {- self.diagnostics_enabled && self.mode.is_full()+ self.diagnostics_enabled && self.lsp_data_enabled()}pub fn inline_diagnostics_enabled(&self) -> bool {@@ -19771,10 +19776,7 @@ impl Editor {// `ActiveDiagnostic::All` is a special mode where editor's diagnostics are managed by the external view,// skip any LSP updates for it.- if self.active_diagnostics == ActiveDiagnostic::All- || !self.mode().is_full()- || !self.diagnostics_enabled()- {+ if self.active_diagnostics == ActiveDiagnostic::All || !self.diagnostics_enabled() {return None;}let pull_diagnostics_settings = ProjectSettings::get_global(cx)@@ -25628,13 +25630,17 @@ impl Editor {}}+ fn lsp_data_enabled(&self) -> bool {+ self.enable_lsp_data && self.mode().is_full()+ }+fn update_lsp_data(&mut self,for_buffer: Option<BufferId>,window: &mut Window,cx: &mut Context<'_, Self>,) {- if !self.enable_lsp_data {+ if !self.lsp_data_enabled() {return;}@@ -25648,7 +25654,7 @@ impl Editor {}fn register_visible_buffers(&mut self, cx: &mut Context<Self>) {- if !self.mode().is_full() {+ if !self.lsp_data_enabled() {return;}for (_, (visible_buffer, _, _)) in self.visible_excerpts(true, cx) {@@ -25657,7 +25663,7 @@ impl Editor {}fn register_buffer(&mut self, buffer_id: BufferId, cx: &mut Context<Self>) {- if !self.mode().is_full() {+ if !self.lsp_data_enabled() {return;}diff --git a/crates/editor/src/folding_ranges.rs b/crates/editor/src/folding_ranges.rsindex 593095b0047..745fdcbe30a 100644--- a/crates/editor/src/folding_ranges.rs+++ b/crates/editor/src/folding_ranges.rs@@ -13,7 +13,7 @@ impl Editor {_window: &Window,cx: &mut Context<Self>,) {- if !self.mode().is_full() || !self.use_document_folding_ranges {+ if !self.lsp_data_enabled() || !self.use_document_folding_ranges {return;}let Some(project) = self.project.clone() else {diff --git a/crates/editor/src/inlays/inlay_hints.rs b/crates/editor/src/inlays/inlay_hints.rsindex 0b3f6bda09c..62eb35f1ac8 100644--- a/crates/editor/src/inlays/inlay_hints.rs+++ b/crates/editor/src/inlays/inlay_hints.rs@@ -292,7 +292,7 @@ impl Editor {reason: InlayHintRefreshReason,cx: &mut Context<Self>,) {- if !self.mode().is_full() || self.inlay_hints.is_none() {+ if !self.lsp_data_enabled() || self.inlay_hints.is_none() {return;}let Some(semantics_provider) = self.semantics_provider() else {diff --git a/crates/editor/src/linked_editing_ranges.rs b/crates/editor/src/linked_editing_ranges.rsindex 34fc1e97df2..ccd0e64bd85 100644--- a/crates/editor/src/linked_editing_ranges.rs+++ b/crates/editor/src/linked_editing_ranges.rs@@ -50,7 +50,7 @@ pub(super) fn refresh_linked_ranges(window: &mut Window,cx: &mut Context<Editor>,) -> Option<()> {- if !editor.mode().is_full() || editor.pending_rename.is_some() {+ if !editor.lsp_data_enabled() || editor.pending_rename.is_some() {return None;}let project = editor.project()?.downgrade();diff --git a/crates/editor/src/semantic_tokens.rs b/crates/editor/src/semantic_tokens.rsindex 31a573f0478..e95b20aed5a 100644--- a/crates/editor/src/semantic_tokens.rs+++ b/crates/editor/src/semantic_tokens.rs@@ -119,7 +119,7 @@ impl Editor {for_server: Option<RefreshForServer>,cx: &mut Context<Self>,) {- if !self.mode().is_full() || !self.semantic_token_state.enabled() {+ if !self.lsp_data_enabled() || !self.semantic_token_state.enabled() {self.invalidate_semantic_tokens(None);self.display_map.update(cx, |display_map, _| {match Arc::get_mut(&mut display_map.semantic_token_highlights) {diff --git a/crates/editor/src/split.rs b/crates/editor/src/split.rsindex 4e5f8ebf279..877f388fc3b 100644--- a/crates/editor/src/split.rs+++ b/crates/editor/src/split.rs@@ -446,6 +446,9 @@ impl SplittableEditor {let mut editor =Editor::for_multibuffer(rhs_multibuffer.clone(), Some(project.clone()), window, cx);editor.set_expand_all_diff_hunks(cx);+ editor.disable_runnables();+ editor.disable_diagnostics(cx);+ editor.set_minimap_visibility(crate::MinimapVisibility::Disabled, window, cx);editor});// TODO(split-diff) we might want to tag editor events with whether they came from rhs/lhs