Add a way to clear activity indicator (#30156)
Follow-up of https://github.com/zed-industries/zed/pull/30015 * Restyles the dismiss and close buttons a bit: change the dismiss icon and add tooltips with the bindings to both * Allows ESC to clear any status that's in the activity indicator now, if all notifications are cleared: this won't suppress any further status additions though, so statuses may resurface later Release Notes: - Added a way to clear activity indicator
This commit is contained in:
parent
77ac82587a
commit
6e19c9b141
5 changed files with 88 additions and 19 deletions
|
@ -43,6 +43,7 @@ pub struct ActivityIndicator {
|
|||
context_menu_handle: PopoverMenuHandle<ContextMenu>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct ServerStatus {
|
||||
name: SharedString,
|
||||
status: BinaryStatus,
|
||||
|
@ -70,6 +71,7 @@ impl ActivityIndicator {
|
|||
) -> Entity<ActivityIndicator> {
|
||||
let project = workspace.project().clone();
|
||||
let auto_updater = AutoUpdater::get(cx);
|
||||
let workspace_handle = cx.entity();
|
||||
let this = cx.new(|cx| {
|
||||
let mut status_events = languages.language_server_binary_statuses();
|
||||
cx.spawn(async move |this, cx| {
|
||||
|
@ -84,6 +86,25 @@ impl ActivityIndicator {
|
|||
})
|
||||
.detach();
|
||||
|
||||
cx.subscribe_in(
|
||||
&workspace_handle,
|
||||
window,
|
||||
|activity_indicator, _, event, window, cx| match event {
|
||||
workspace::Event::ClearActivityIndicator { .. } => {
|
||||
if activity_indicator.statuses.pop().is_some() {
|
||||
activity_indicator.dismiss_error_message(
|
||||
&DismissErrorMessage,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
)
|
||||
.detach();
|
||||
|
||||
cx.subscribe(
|
||||
&project.read(cx).lsp_store(),
|
||||
|_, _, event, cx| match event {
|
||||
|
@ -115,7 +136,7 @@ impl ActivityIndicator {
|
|||
}
|
||||
|
||||
Self {
|
||||
statuses: Default::default(),
|
||||
statuses: Vec::new(),
|
||||
project: project.clone(),
|
||||
auto_updater,
|
||||
context_menu_handle: Default::default(),
|
||||
|
@ -185,11 +206,8 @@ impl ActivityIndicator {
|
|||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if let Some(updater) = &self.auto_updater {
|
||||
updater.update(cx, |updater, cx| {
|
||||
updater.dismiss_error(cx);
|
||||
});
|
||||
updater.update(cx, |updater, cx| updater.dismiss_error(cx));
|
||||
}
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn pending_language_server_work<'a>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue