mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Activate the *newest* existing project find view on cmd-shift-F
This commit is contained in:
parent
2f427769df
commit
e96d0a9355
@ -386,7 +386,10 @@ impl ItemView for ProjectFindView {
|
||||
|
||||
impl ProjectFindView {
|
||||
fn deploy(workspace: &mut Workspace, _: &Deploy, cx: &mut ViewContext<Workspace>) {
|
||||
if let Some(existing) = workspace.item_of_type::<ProjectFind>(cx) {
|
||||
if let Some(existing) = workspace
|
||||
.items_of_type::<ProjectFind>(cx)
|
||||
.max_by_key(|existing| existing.id())
|
||||
{
|
||||
workspace.activate_item(&existing, cx);
|
||||
} else {
|
||||
let model = cx.add_model(|cx| ProjectFind::new(workspace.project().clone(), cx));
|
||||
|
@ -826,6 +826,15 @@ impl Workspace {
|
||||
.find_map(|i| i.upgrade(cx).and_then(|i| i.to_any().downcast()))
|
||||
}
|
||||
|
||||
pub fn items_of_type<'a, T: Item>(
|
||||
&'a self,
|
||||
cx: &'a AppContext,
|
||||
) -> impl 'a + Iterator<Item = ModelHandle<T>> {
|
||||
self.items
|
||||
.iter()
|
||||
.filter_map(|i| i.upgrade(cx).and_then(|i| i.to_any().downcast()))
|
||||
}
|
||||
|
||||
pub fn active_item(&self, cx: &AppContext) -> Option<Box<dyn ItemViewHandle>> {
|
||||
self.active_pane().read(cx).active_item()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user