Merge pull request #2303 from zed-industries/add-unknown-language

Add an 'Unknown' state for a mouse-driven way to select a file language
This commit is contained in:
Mikayla Maki 2023-03-17 11:41:40 -07:00 committed by GitHub
commit 459e320d79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,21 +50,23 @@ impl View for ActiveBufferLanguage {
}
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
if let Some(active_language) = self.active_language.as_ref() {
MouseEventHandler::<Self>::new(0, cx, |state, cx| {
let theme = &cx.global::<Settings>().theme.workspace.status_bar;
let style = theme.active_language.style_for(state, false);
Label::new(active_language.to_string(), style.text.clone())
.contained()
.with_style(style.container)
.boxed()
})
.with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, cx| cx.dispatch_action(crate::Toggle))
.boxed()
let active_language = if let Some(active_language) = self.active_language.as_ref() {
active_language.to_string()
} else {
Empty::new().boxed()
}
"Unkown".to_string()
};
MouseEventHandler::<Self>::new(0, cx, |state, cx| {
let theme = &cx.global::<Settings>().theme.workspace.status_bar;
let style = theme.active_language.style_for(state, false);
Label::new(active_language, style.text.clone())
.contained()
.with_style(style.container)
.boxed()
})
.with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, cx| cx.dispatch_action(crate::Toggle))
.boxed()
}
}