Merge branch 'project-diagnostics-pinned-tab' into style-project-diagnostics

This commit is contained in:
Max Brunsfeld 2022-01-25 12:20:37 -08:00
commit c9b4bb78f2
13 changed files with 118 additions and 70 deletions

View file

@ -70,8 +70,6 @@ pub enum Event {
Split(SplitDirection),
}
const MAX_TAB_TITLE_LEN: usize = 24;
pub struct Pane {
item_views: Vec<(usize, Box<dyn ItemViewHandle>)>,
active_item_index: usize,
@ -79,6 +77,11 @@ pub struct Pane {
nav_history: Rc<RefCell<NavHistory>>,
}
// #[derive(Debug, Eq, PartialEq)]
// pub struct State {
// pub tabs: Vec<TabState>,
// }
pub struct ItemNavHistory {
history: Rc<RefCell<NavHistory>>,
item_view: Rc<dyn WeakItemViewHandle>,
@ -373,15 +376,12 @@ impl Pane {
let is_active = ix == self.active_item_index;
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()
@ -430,29 +430,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(