Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Reintroduce LSP diagnostic/status message
Julia0390fb1449da
diff --git a/crates/activity_indicator2/src/activity_indicator.rs b/crates/activity_indicator2/src/activity_indicator.rsindex e4a5b01ba6b..f83517e0618 100644--- a/crates/activity_indicator2/src/activity_indicator.rs+++ b/crates/activity_indicator2/src/activity_indicator.rs@@ -10,7 +10,7 @@ use language::{LanguageRegistry, LanguageServerBinaryStatus};use project::{LanguageServerProgress, Project};use smallvec::SmallVec;use std::{cmp::Reverse, fmt::Write, sync::Arc};-use ui::h_stack;+use ui::{h_stack, Label};use util::ResultExt;use workspace::{item::ItemHandle, StatusItemView, Workspace};@@ -324,7 +324,7 @@ impl Render for ActivityIndicator {result.children(content.icon.map(|icon| svg().path(icon)))- .child(SharedString::from(content.message))+ .child(Label::new(SharedString::from(content.message)))}}diff --git a/crates/diagnostics2/src/items.rs b/crates/diagnostics2/src/items.rsindex 92b0641deae..28bbe7aedc2 100644--- a/crates/diagnostics2/src/items.rs+++ b/crates/diagnostics2/src/items.rs@@ -1,13 +1,13 @@use collections::HashSet;use editor::{Editor, GoToDiagnostic};use gpui::{- rems, Div, EventEmitter, InteractiveElement, ParentElement, Render, Stateful,+ rems, Div, EventEmitter, InteractiveElement, IntoElement, ParentElement, Render, Stateful,StatefulInteractiveElement, Styled, Subscription, View, ViewContext, WeakView,};use language::Diagnostic;use lsp::LanguageServerId;use theme::ActiveTheme;-use ui::{h_stack, Color, Icon, IconElement, Label, Tooltip};+use ui::{h_stack, Button, Clickable, Color, Icon, IconElement, Label, Tooltip};use workspace::{item::ItemHandle, StatusItemView, ToolbarItemEvent, Workspace};use crate::ProjectDiagnosticsEditor;@@ -43,13 +43,28 @@ impl Render for DiagnosticIndicator {.child(Label::new(warning_count.to_string())),};+ let status = if !self.in_progress_checks.is_empty() {+ Some(Label::new("Checking…").into_any_element())+ } else if let Some(diagnostic) = &self.current_diagnostic {+ let message = diagnostic.message.split('\n').next().unwrap().to_string();+ Some(+ Button::new("diagnostic_message", message)+ .on_click(cx.listener(|this, _, cx| {+ this.go_to_next_diagnostic(&GoToDiagnostic, cx);+ }))+ .into_any_element(),+ )+ } else {+ None+ };+h_stack().id("diagnostic-indicator").on_action(cx.listener(Self::go_to_next_diagnostic)).rounded_md().flex_none().h(rems(1.375))- .px_1()+ .px_6().cursor_pointer().bg(cx.theme().colors().ghost_element_background).hover(|style| style.bg(cx.theme().colors().ghost_element_hover))@@ -63,6 +78,7 @@ impl Render for DiagnosticIndicator {}})).child(diagnostic_indicator)+ .children(status)}}diff --git a/crates/workspace2/src/pane.rs b/crates/workspace2/src/pane.rsindex e1bb006c114..dcf4ed08116 100644--- a/crates/workspace2/src/pane.rs+++ b/crates/workspace2/src/pane.rs@@ -789,6 +789,7 @@ impl Pane {}self.update_toolbar(cx);+ self.update_status_bar(cx);if focus_item {self.focus_active_item(cx);@@ -1450,6 +1451,22 @@ impl Pane {});}+ fn update_status_bar(&mut self, cx: &mut ViewContext<Self>) {+ let Ok(status_bar) = self+ .workspace+ .update(cx, |workspace, _| workspace.status_bar.clone())+ else {+ return;+ };++ let pane = cx.view().clone();+ cx.window_context().defer(move |cx| {+ status_bar.update(cx, move |status_bar, cx| {+ status_bar.set_active_pane(&pane, cx);+ });+ });+ }+fn render_tab(&self,ix: usize,diff --git a/crates/workspace2/src/status_bar.rs b/crates/workspace2/src/status_bar.rsindex ba571d6e0ad..f4e4ac9508d 100644--- a/crates/workspace2/src/status_bar.rs+++ b/crates/workspace2/src/status_bar.rs@@ -83,6 +83,9 @@ impl StatusBar {whereT: 'static + StatusItemView,{+ let active_pane_item = self.active_pane.read(cx).active_item();+ item.set_active_pane_item(active_pane_item.as_deref(), cx);+self.left_items.push(Box::new(item));cx.notify();}@@ -119,6 +122,9 @@ impl StatusBar {) whereT: 'static + StatusItemView,{+ let active_pane_item = self.active_pane.read(cx).active_item();+ item.set_active_pane_item(active_pane_item.as_deref(), cx);+if position < self.left_items.len() {self.left_items.insert(position + 1, Box::new(item))} else {@@ -141,6 +147,9 @@ impl StatusBar {whereT: 'static + StatusItemView,{+ let active_pane_item = self.active_pane.read(cx).active_item();+ item.set_active_pane_item(active_pane_item.as_deref(), cx);+self.right_items.push(Box::new(item));cx.notify();}