This commit is contained in:
Mikayla Maki 2023-05-30 16:33:42 -07:00
parent 685e8d7007
commit 0122cd61c5
No known key found for this signature in database
6 changed files with 25 additions and 24 deletions

View file

@ -517,7 +517,8 @@ impl View for PanelButtons {
&*tooltip_action,
)
.ok();
}).detach();
})
.detach();
}
}
})

View file

@ -2,8 +2,8 @@ mod dragged_item_receiver;
use super::{ItemHandle, SplitDirection};
use crate::{
item::WeakItemHandle, toolbar::Toolbar, AutosaveSetting, Item, NewFile, NewSearch,
ToggleZoom, Workspace, WorkspaceSettings, NewCenterTerminal,
item::WeakItemHandle, toolbar::Toolbar, AutosaveSetting, Item, NewCenterTerminal, NewFile,
NewSearch, ToggleZoom, Workspace, WorkspaceSettings,
};
use anyhow::Result;
use collections::{HashMap, HashSet, VecDeque};

View file

@ -53,9 +53,10 @@ use std::{
cmp, env,
future::Future,
path::{Path, PathBuf},
rc::Rc,
str,
sync::{atomic::AtomicUsize, Arc},
time::Duration, rc::Rc,
time::Duration,
};
use crate::{
@ -1623,14 +1624,21 @@ impl Workspace {
}
pub fn focus_panel<T: Panel>(&mut self, cx: &mut ViewContext<Self>) -> Option<ViewHandle<T>> {
self.show_or_hide_panel::<T>(cx, |_, _| true)?.as_any().clone().downcast()
self.show_or_hide_panel::<T>(cx, |_, _| true)?
.as_any()
.clone()
.downcast()
}
pub fn toggle_panel_focus<T: Panel>(&mut self, cx: &mut ViewContext<Self>) {
self.show_or_hide_panel::<T>(cx, |panel, cx| !panel.has_focus(cx));
}
fn show_or_hide_panel<T: Panel>(&mut self, cx: &mut ViewContext<Self>, show: impl Fn(&dyn PanelHandle, &mut ViewContext<Dock>) -> bool) -> Option<Rc<dyn PanelHandle>> {
fn show_or_hide_panel<T: Panel>(
&mut self,
cx: &mut ViewContext<Self>,
show: impl Fn(&dyn PanelHandle, &mut ViewContext<Dock>) -> bool,
) -> Option<Rc<dyn PanelHandle>> {
for (dock, position) in [
self.left_dock.clone(),
self.bottom_dock.clone(),