Show error+warning counts in project diagnostics tab

Allow workspace items' tab contents to be arbitrary elements

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld 2022-01-11 17:23:11 -08:00
parent 6ad9ff10c1
commit 6865a42df9
13 changed files with 121 additions and 77 deletions

View file

@ -55,8 +55,6 @@ pub enum Event {
Split(SplitDirection),
}
const MAX_TAB_TITLE_LEN: usize = 24;
#[derive(Debug, Eq, PartialEq)]
pub struct State {
pub tabs: Vec<TabState>,
@ -213,15 +211,12 @@ impl Pane {
let is_active = ix == self.active_item;
row.add_child({
let mut title = item_view.title(cx);
if title.len() > MAX_TAB_TITLE_LEN {
let mut truncated_len = MAX_TAB_TITLE_LEN;
while !title.is_char_boundary(truncated_len) {
truncated_len -= 1;
}
title.truncate(truncated_len);
title.push('…');
}
let tab_style = if is_active {
theme.workspace.active_tab.clone()
} else {
theme.workspace.tab.clone()
};
let title = item_view.tab_content(&tab_style, cx);
let mut style = if is_active {
theme.workspace.active_tab.clone()
@ -270,29 +265,16 @@ impl Pane {
.boxed(),
)
.with_child(
Container::new(
Align::new(
Label::new(
title,
if is_active {
theme.workspace.active_tab.label.clone()
} else {
theme.workspace.tab.label.clone()
},
)
.boxed(),
)
.boxed(),
)
.with_style(ContainerStyle {
margin: Margin {
left: style.spacing,
right: style.spacing,
Container::new(Align::new(title).boxed())
.with_style(ContainerStyle {
margin: Margin {
left: style.spacing,
right: style.spacing,
..Default::default()
},
..Default::default()
},
..Default::default()
})
.boxed(),
})
.boxed(),
)
.with_child(
Align::new(