diff --git a/crates/activity_indicator2/src/activity_indicator.rs b/crates/activity_indicator2/src/activity_indicator.rs index e4a5b01ba6bdb276f00d20f3f7748b771c2b2ed8..f83517e0618316a5407f5ab6a9bc3cabc653033a 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.rs index 92b0641deae4d049fda3d968cf88b28568b50d41..28bbe7aedc29c84578f5d01abd7d06febb51ac95 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.rs index e1bb006c11428149d5ade09aed2db137e7e61cdb..dcf4ed0811650ce85d961cee0fabd433f219c593 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) { + 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.rs index ba571d6e0ad3c70bc64139e90e64f9c59314bfc7..f4e4ac9508dc4fae74913c5eefb59c39802b38e7 100644 --- a/crates/workspace2/src/status_bar.rs +++ b/crates/workspace2/src/status_bar.rs @@ -83,6 +83,9 @@ impl StatusBar { where T: '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 { ) where T: '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 { where T: '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(); }