Get diagnostics view almost building in the zed2 world
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
@@ -619,11 +619,11 @@ impl Pane {
|
||||
self.items.iter()
|
||||
}
|
||||
|
||||
// pub fn items_of_type<T: View>(&self) -> impl '_ + Iterator<Item = ViewHandle<T>> {
|
||||
// self.items
|
||||
// .iter()
|
||||
// .filter_map(|item| item.as_any().clone().downcast())
|
||||
// }
|
||||
pub fn items_of_type<T: 'static>(&self) -> impl '_ + Iterator<Item = View<T>> {
|
||||
self.items
|
||||
.iter()
|
||||
.filter_map(|item| item.to_any().clone().downcast().ok())
|
||||
}
|
||||
|
||||
pub fn active_item(&self) -> Option<Box<dyn ItemHandle>> {
|
||||
self.items.get(self.active_item_index).cloned()
|
||||
|
||||
@@ -67,7 +67,7 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
use theme2::{ActiveTheme, ThemeSettings};
|
||||
pub use toolbar::{ToolbarItemLocation, ToolbarItemView};
|
||||
pub use toolbar::{ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView};
|
||||
use ui::TextColor;
|
||||
use ui::{h_stack, Button, ButtonVariant, KeyBinding, Label, TextTooltip};
|
||||
use util::ResultExt;
|
||||
@@ -1433,18 +1433,18 @@ impl Workspace {
|
||||
self.panes.iter().flat_map(|pane| pane.read(cx).items())
|
||||
}
|
||||
|
||||
// pub fn item_of_type<T: Item>(&self, cx: &AppContext) -> Option<View<T>> {
|
||||
// self.items_of_type(cx).max_by_key(|item| item.id())
|
||||
// }
|
||||
pub fn item_of_type<T: Item>(&self, cx: &AppContext) -> Option<View<T>> {
|
||||
self.items_of_type(cx).max_by_key(|item| item.entity_id())
|
||||
}
|
||||
|
||||
// pub fn items_of_type<'a, T: Item>(
|
||||
// &'a self,
|
||||
// cx: &'a AppContext,
|
||||
// ) -> impl 'a + Iterator<Item = View<T>> {
|
||||
// self.panes
|
||||
// .iter()
|
||||
// .flat_map(|pane| pane.read(cx).items_of_type())
|
||||
// }
|
||||
pub fn items_of_type<'a, T: Item>(
|
||||
&'a self,
|
||||
cx: &'a AppContext,
|
||||
) -> impl 'a + Iterator<Item = View<T>> {
|
||||
self.panes
|
||||
.iter()
|
||||
.flat_map(|pane| pane.read(cx).items_of_type())
|
||||
}
|
||||
|
||||
pub fn active_item(&self, cx: &AppContext) -> Option<Box<dyn ItemHandle>> {
|
||||
self.active_pane().read(cx).active_item()
|
||||
|
||||
Reference in New Issue
Block a user