suggested extensions (#9526)

Follow-up from #9138

Release Notes:

- Adds suggested extensions for some filetypes
([#7096](https://github.com/zed-industries/zed/issues/7096)).

---------

Co-authored-by: Felix Zeller <felixazeller@gmail.com>
This commit is contained in:
Conrad Irwin 2024-03-19 10:06:01 -06:00 committed by GitHub
parent 7573f35e8e
commit d6b7f14b51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 318 additions and 37 deletions

View file

@ -285,6 +285,8 @@ pub mod simple_message_notification {
message: SharedString,
on_click: Option<Arc<dyn Fn(&mut ViewContext<Self>)>>,
click_message: Option<SharedString>,
secondary_click_message: Option<SharedString>,
secondary_on_click: Option<Arc<dyn Fn(&mut ViewContext<Self>)>>,
}
impl EventEmitter<DismissEvent> for MessageNotification {}
@ -298,6 +300,8 @@ pub mod simple_message_notification {
message: message.into(),
on_click: None,
click_message: None,
secondary_on_click: None,
secondary_click_message: None,
}
}
@ -317,6 +321,22 @@ pub mod simple_message_notification {
self
}
pub fn with_secondary_click_message<S>(mut self, message: S) -> Self
where
S: Into<SharedString>,
{
self.secondary_click_message = Some(message.into());
self
}
pub fn on_secondary_click<F>(mut self, on_click: F) -> Self
where
F: 'static + Fn(&mut ViewContext<Self>),
{
self.secondary_on_click = Some(Arc::new(on_click));
self
}
pub fn dismiss(&mut self, cx: &mut ViewContext<Self>) {
cx.emit(DismissEvent);
}
@ -339,16 +359,30 @@ pub mod simple_message_notification {
.on_click(cx.listener(|this, _, cx| this.dismiss(cx))),
),
)
.children(self.click_message.iter().map(|message| {
Button::new(message.clone(), message.clone()).on_click(cx.listener(
|this, _, cx| {
if let Some(on_click) = this.on_click.as_ref() {
(on_click)(cx)
};
this.dismiss(cx)
},
))
}))
.child(
h_flex()
.gap_3()
.children(self.click_message.iter().map(|message| {
Button::new(message.clone(), message.clone()).on_click(cx.listener(
|this, _, cx| {
if let Some(on_click) = this.on_click.as_ref() {
(on_click)(cx)
};
this.dismiss(cx)
},
))
}))
.children(self.secondary_click_message.iter().map(|message| {
Button::new(message.clone(), message.clone())
.style(ButtonStyle::Filled)
.on_click(cx.listener(|this, _, cx| {
if let Some(on_click) = this.secondary_on_click.as_ref() {
(on_click)(cx)
};
this.dismiss(cx)
}))
})),
)
}
}
}