diff --git a/crates/editor/src/document_colors.rs b/crates/editor/src/document_colors.rs index 579414c7f91c6b2770951a2439599abc4000b27c..a38a0527f0641ef2d622b2f33fa1e932080ad7b5 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, ) { - 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.rs index b73c1abbfb9bfec86093eed72082232275388faf..0228bbd917ad96b94778b2fc01d3a66e81224296 100644 --- a/crates/editor/src/document_symbols.rs +++ b/crates/editor/src/document_symbols.rs @@ -147,7 +147,7 @@ impl Editor { for_buffer: Option, cx: &mut Context, ) { - 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.rs index aabf16d2b64846388b6b1c0903e280e9f465a41d..a08ac3bbc466d159ce81a7aa3bebf82599914a0b 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) { - 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) -> 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, - ) -> Vec<(Range, language::RunnableRange)> { - snapshot.buffer_snapshot().runnable_ranges(range).collect() - } fn runnable_rows( project: Entity, @@ -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, 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) { - 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) { - 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.rs index 593095b004792be2055b0dc2614d086f114acd5e..745fdcbe30a0aede4f364afd5c58958c74b3da79 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, ) { - 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.rs index 0b3f6bda09c2cf86b994682e2ed89c2614d72737..62eb35f1ac85227c9b52737660da0d1834e1bbfa 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, ) { - 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.rs index 34fc1e97df2b01cb3e35b95ec90d0c8d31f5790a..ccd0e64bd850f6ce84e225fe77f1c0a0d5385dc1 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, ) -> 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.rs index 31a573f04787e3759a6a21ec15f36ec148a80f30..e95b20aed5a6655d6ae4ccd2c6658cfcfecc2ea4 100644 --- a/crates/editor/src/semantic_tokens.rs +++ b/crates/editor/src/semantic_tokens.rs @@ -119,7 +119,7 @@ impl Editor { for_server: Option, cx: &mut Context, ) { - 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.rs index 4e5f8ebf2793f6807e0a9108e12c276a7ab45427..877f388fc3b783202cb29f8ca063446635e4277a 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