Compare commits
2 commits
main
...
focus_on_d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d8a25dee3b | ||
![]() |
0fefe53773 |
5 changed files with 377 additions and 222 deletions
|
@ -214,13 +214,13 @@ impl TerminalPanel {
|
|||
event: &pane::Event,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
match event {
|
||||
match dbg!(event) {
|
||||
pane::Event::ActivateItem { .. } => self.serialize(cx),
|
||||
pane::Event::RemoveItem { .. } => self.serialize(cx),
|
||||
pane::Event::Remove => cx.emit(PanelEvent::Close),
|
||||
pane::Event::ZoomIn => cx.emit(PanelEvent::ZoomIn),
|
||||
pane::Event::ZoomOut => cx.emit(PanelEvent::ZoomOut),
|
||||
pane::Event::Focus => cx.emit(PanelEvent::Focus),
|
||||
pane::Event::Focus => cx.emit(dbg!(PanelEvent::Focus)),
|
||||
|
||||
pane::Event::AddItem { item } => {
|
||||
if let Some(workspace) = self.workspace.upgrade() {
|
||||
|
|
|
@ -1025,11 +1025,13 @@ impl Workspace {
|
|||
if !panel.has_focus(cx) {
|
||||
cx.focus(&panel);
|
||||
}
|
||||
dbg!("D");
|
||||
this.zoomed = Some(panel.downgrade().into_any());
|
||||
this.zoomed_position = Some(panel.read(cx).position(cx));
|
||||
} else if T::should_zoom_out_on_event(event) {
|
||||
dock.update(cx, |dock, cx| dock.set_panel_zoomed(&panel, false, cx));
|
||||
if this.zoomed_position == Some(prev_position) {
|
||||
dbg!("Losing focus A");
|
||||
this.zoomed = None;
|
||||
this.zoomed_position = None;
|
||||
}
|
||||
|
@ -1038,9 +1040,11 @@ impl Workspace {
|
|||
let position = panel.read(cx).position(cx);
|
||||
this.dismiss_zoomed_items_to_reveal(Some(position), cx);
|
||||
if panel.is_zoomed(cx) {
|
||||
dbg!("C");
|
||||
this.zoomed = Some(panel.downgrade().into_any());
|
||||
this.zoomed_position = Some(position);
|
||||
} else {
|
||||
dbg!("Losing focus B");
|
||||
this.zoomed = None;
|
||||
this.zoomed_position = None;
|
||||
}
|
||||
|
@ -1831,7 +1835,7 @@ impl Workspace {
|
|||
self.dismiss_zoomed_items_to_reveal(Some(dock_side), cx);
|
||||
}
|
||||
|
||||
if focus_center {
|
||||
if dbg!(focus_center) {
|
||||
cx.focus_self();
|
||||
}
|
||||
|
||||
|
@ -1875,6 +1879,7 @@ impl Workspace {
|
|||
) -> Option<Rc<dyn PanelHandle>> {
|
||||
for dock in [&self.left_dock, &self.bottom_dock, &self.right_dock] {
|
||||
if let Some(panel_index) = dock.read(cx).panel_index_for_type::<T>() {
|
||||
dbg!(panel_index);
|
||||
let mut focus_center = false;
|
||||
let mut reveal_dock = false;
|
||||
let panel = dock.update(cx, |dock, cx| {
|
||||
|
@ -1926,6 +1931,7 @@ impl Workspace {
|
|||
self.left_dock.update(cx, |dock, cx| dock.zoom_out(cx));
|
||||
self.bottom_dock.update(cx, |dock, cx| dock.zoom_out(cx));
|
||||
self.right_dock.update(cx, |dock, cx| dock.zoom_out(cx));
|
||||
dbg!("Losing focus C");
|
||||
self.zoomed = None;
|
||||
self.zoomed_position = None;
|
||||
|
||||
|
@ -1969,6 +1975,7 @@ impl Workspace {
|
|||
}
|
||||
|
||||
if self.zoomed_position != dock_to_reveal {
|
||||
dbg!("losing D");
|
||||
self.zoomed = None;
|
||||
self.zoomed_position = None;
|
||||
}
|
||||
|
@ -2313,8 +2320,10 @@ impl Workspace {
|
|||
|
||||
self.dismiss_zoomed_items_to_reveal(None, cx);
|
||||
if pane.read(cx).is_zoomed() {
|
||||
dbg!("B");
|
||||
self.zoomed = Some(pane.downgrade().into_any());
|
||||
} else {
|
||||
dbg!("losing focus E");
|
||||
self.zoomed = None;
|
||||
}
|
||||
self.zoomed_position = None;
|
||||
|
@ -2364,6 +2373,7 @@ impl Workspace {
|
|||
if pane == self.active_pane {
|
||||
pane.update(cx, |pane, cx| pane.set_zoomed(true, cx));
|
||||
if pane.read(cx).has_focus() {
|
||||
dbg!("A");
|
||||
self.zoomed = Some(pane.downgrade().into_any());
|
||||
self.zoomed_position = None;
|
||||
}
|
||||
|
@ -2373,6 +2383,7 @@ impl Workspace {
|
|||
pane::Event::ZoomOut => {
|
||||
pane.update(cx, |pane, cx| pane.set_zoomed(false, cx));
|
||||
if self.zoomed_position.is_none() {
|
||||
dbg!("losing focus F");
|
||||
self.zoomed = None;
|
||||
}
|
||||
cx.notify();
|
||||
|
|
|
@ -10,6 +10,7 @@ use std::sync::Arc;
|
|||
use ui::{h_stack, ContextMenu, IconButton, Tooltip};
|
||||
use ui::{prelude::*, right_click_menu};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum PanelEvent {
|
||||
ChangePosition,
|
||||
ZoomIn,
|
||||
|
@ -286,9 +287,11 @@ impl Dock {
|
|||
workspace: WeakView<Workspace>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
let self_view = cx.view().downgrade();
|
||||
let subscriptions = [
|
||||
cx.observe(&panel, |_, _, cx| cx.notify()),
|
||||
cx.subscribe(&panel, move |this, panel, event, cx| match event {
|
||||
cx.window_context()
|
||||
.subscribe(&panel, move |panel, event, cx| match dbg!(event) {
|
||||
PanelEvent::ChangePosition => {
|
||||
let new_position = panel.read(cx).position(cx);
|
||||
|
||||
|
@ -306,23 +309,31 @@ impl Dock {
|
|||
return;
|
||||
};
|
||||
|
||||
let was_visible = this.is_open()
|
||||
let Ok(was_visible) = self_view.update(cx, |this, cx| {
|
||||
this.is_open()
|
||||
&& this.visible_panel().map_or(false, |active_panel| {
|
||||
active_panel.entity_id() == Entity::entity_id(&panel)
|
||||
});
|
||||
})
|
||||
}) else {
|
||||
return;
|
||||
};
|
||||
|
||||
this.remove_panel(&panel, cx);
|
||||
self_view.update(cx, |this, cx| this.remove_panel(&panel, cx));
|
||||
|
||||
new_dock.update(cx, |new_dock, cx| {
|
||||
new_dock.add_panel(panel.clone(), workspace.clone(), cx);
|
||||
if was_visible {
|
||||
new_dock.set_open(true, cx);
|
||||
new_dock.activate_panel(this.panels_len() - 1, cx);
|
||||
self_view.update(cx, |this, cx| {
|
||||
new_dock.activate_panel(this.panels_len() - 1, cx)
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
PanelEvent::ZoomIn => {
|
||||
this.set_panel_zoomed(&panel.to_any(), true, cx);
|
||||
self_view.update(cx, |this, cx| {
|
||||
this.set_panel_zoomed(&panel.to_any(), true, cx)
|
||||
});
|
||||
if !panel.focus_handle(cx).contains_focused(cx) {
|
||||
cx.focus_view(&panel);
|
||||
}
|
||||
|
@ -334,10 +345,16 @@ impl Dock {
|
|||
.ok();
|
||||
}
|
||||
PanelEvent::ZoomOut => {
|
||||
this.set_panel_zoomed(&panel.to_any(), false, cx);
|
||||
self_view.update(cx, |this, cx| {
|
||||
this.set_panel_zoomed(&panel.to_any(), false, cx)
|
||||
});
|
||||
workspace
|
||||
.update(cx, |workspace, cx| {
|
||||
if workspace.zoomed_position == Some(this.position) {
|
||||
if workspace.zoomed_position
|
||||
== Some(self_view.update(cx, |this, cx| this.position).ok())
|
||||
.flatten()
|
||||
{
|
||||
dbg!("Losing focus A");
|
||||
workspace.zoomed = None;
|
||||
workspace.zoomed_position = None;
|
||||
}
|
||||
|
@ -346,25 +363,66 @@ impl Dock {
|
|||
.ok();
|
||||
}
|
||||
PanelEvent::Activate => {
|
||||
if let Some(ix) = this
|
||||
.panel_entries
|
||||
.iter()
|
||||
.position(|entry| entry.panel.entity_id() == Entity::entity_id(&panel))
|
||||
{
|
||||
if self_view
|
||||
.update(cx, |this, cx| {
|
||||
if let Some(ix) = this.panel_entries.iter().position(|entry| {
|
||||
entry.panel.entity_id() == Entity::entity_id(&panel)
|
||||
}) {
|
||||
this.set_open(true, cx);
|
||||
this.activate_panel(ix, cx);
|
||||
return true;
|
||||
}
|
||||
false
|
||||
})
|
||||
.ok()
|
||||
.unwrap_or(false)
|
||||
{
|
||||
cx.focus_view(&panel);
|
||||
}
|
||||
}
|
||||
PanelEvent::Close => {
|
||||
self_view
|
||||
.update(cx, |this, cx| {
|
||||
if this
|
||||
.visible_panel()
|
||||
.map_or(false, |p| p.entity_id() == Entity::entity_id(&panel))
|
||||
{
|
||||
this.set_open(false, cx);
|
||||
}
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
PanelEvent::Focus => {
|
||||
let position = panel.read(cx).position(cx);
|
||||
workspace
|
||||
.update(cx, |this, cx| {
|
||||
this.dismiss_zoomed_items_to_reveal(Some(position), cx)
|
||||
})
|
||||
.ok();
|
||||
if panel.is_zoomed(cx) {
|
||||
dbg!("C");
|
||||
workspace
|
||||
.update(cx, |this, cx| {
|
||||
this.zoomed = Some(panel.downgrade().into());
|
||||
this.zoomed_position = Some(position);
|
||||
})
|
||||
.ok();
|
||||
} else {
|
||||
workspace
|
||||
.update(cx, |this, cx| {
|
||||
dbg!("Losing focus B");
|
||||
this.zoomed = None;
|
||||
this.zoomed_position = None;
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
workspace
|
||||
.update(cx, |this, cx| {
|
||||
this.update_active_view_for_followers(cx);
|
||||
})
|
||||
.ok();
|
||||
cx.notify();
|
||||
}
|
||||
PanelEvent::Focus => todo!(),
|
||||
}),
|
||||
];
|
||||
|
||||
|
@ -775,12 +833,18 @@ pub mod test {
|
|||
impl EventEmitter<PanelEvent> for TestPanel {}
|
||||
|
||||
impl TestPanel {
|
||||
pub fn new(position: DockPosition, cx: &mut WindowContext) -> Self {
|
||||
pub fn new(position: DockPosition, cx: &mut ViewContext<Self>) -> Self {
|
||||
cx.emit(PanelEvent::Focus);
|
||||
let focus_handle = cx.focus_handle();
|
||||
cx.on_focus_in(&focus_handle, move |_, cx| {
|
||||
cx.emit(PanelEvent::Focus);
|
||||
})
|
||||
.detach();
|
||||
Self {
|
||||
position,
|
||||
zoomed: false,
|
||||
active: false,
|
||||
focus_handle: cx.focus_handle(),
|
||||
focus_handle,
|
||||
size: 300.,
|
||||
}
|
||||
}
|
||||
|
@ -832,12 +896,24 @@ pub mod test {
|
|||
self.zoomed
|
||||
}
|
||||
|
||||
fn set_zoomed(&mut self, zoomed: bool, _cx: &mut ViewContext<Self>) {
|
||||
fn set_zoomed(&mut self, zoomed: bool, cx: &mut ViewContext<Self>) {
|
||||
self.zoomed = zoomed;
|
||||
let event = if zoomed {
|
||||
PanelEvent::ZoomIn
|
||||
} else {
|
||||
PanelEvent::ZoomOut
|
||||
};
|
||||
cx.emit(event)
|
||||
}
|
||||
|
||||
fn set_active(&mut self, active: bool, _cx: &mut ViewContext<Self>) {
|
||||
self.active = active;
|
||||
fn set_active(&mut self, active: bool, cx: &mut ViewContext<Self>) {
|
||||
self.active = dbg!(active);
|
||||
// let event = if active {
|
||||
// PanelEvent::Activate
|
||||
// } else {
|
||||
// PanelEvent::Close
|
||||
// };
|
||||
// cx.emit(event)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1493,7 +1493,7 @@ impl Pane {
|
|||
.child(label);
|
||||
|
||||
right_click_menu(ix).trigger(tab).menu(|cx| {
|
||||
ContextMenu::build(cx, |menu, cx| {
|
||||
ContextMenu::build(cx, |menu, _| {
|
||||
menu.action("Close", CloseActiveItem { save_intent: None }.boxed_clone())
|
||||
.action("Close Others", CloseInactiveItems.boxed_clone())
|
||||
.separator()
|
||||
|
@ -2057,13 +2057,13 @@ impl Render for Pane {
|
|||
.overflow_hidden()
|
||||
.on_focus_in({
|
||||
let this = this.clone();
|
||||
move |event, cx| {
|
||||
move |_, cx| {
|
||||
this.update(cx, |this, cx| this.focus_in(cx)).ok();
|
||||
}
|
||||
})
|
||||
.on_focus_out({
|
||||
let this = this.clone();
|
||||
move |event, cx| {
|
||||
move |_, cx| {
|
||||
this.update(cx, |this, cx| this.focus_out(cx)).ok();
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1542,13 +1542,16 @@ impl Workspace {
|
|||
dock.set_open(!was_visible, cx);
|
||||
|
||||
if let Some(active_panel) = dock.active_panel() {
|
||||
dbg!(dock_side);
|
||||
if was_visible {
|
||||
if active_panel.focus_handle(cx).contains_focused(cx) {
|
||||
focus_center = true;
|
||||
}
|
||||
} else {
|
||||
let focus_handle = &active_panel.focus_handle(cx);
|
||||
dbg!(&focus_handle);
|
||||
cx.focus(focus_handle);
|
||||
assert!(focus_handle.is_focused(cx));
|
||||
reveal_dock = true;
|
||||
}
|
||||
}
|
||||
|
@ -1558,6 +1561,7 @@ impl Workspace {
|
|||
self.dismiss_zoomed_items_to_reveal(Some(dock_side), cx);
|
||||
}
|
||||
|
||||
dbg!(focus_center);
|
||||
if focus_center {
|
||||
self.active_pane.update(cx, |pane, cx| pane.focus(cx))
|
||||
}
|
||||
|
@ -1603,6 +1607,7 @@ impl Workspace {
|
|||
) -> Option<Arc<dyn PanelHandle>> {
|
||||
for dock in [&self.left_dock, &self.bottom_dock, &self.right_dock] {
|
||||
if let Some(panel_index) = dock.read(cx).panel_index_for_type::<T>() {
|
||||
dbg!(panel_index);
|
||||
let mut focus_center = false;
|
||||
let mut reveal_dock = false;
|
||||
let panel = dock.update(cx, |dock, cx| {
|
||||
|
@ -1615,9 +1620,9 @@ impl Workspace {
|
|||
panel.focus_handle(cx).focus(cx);
|
||||
reveal_dock = true;
|
||||
} else {
|
||||
// if panel.is_zoomed(cx) {
|
||||
// dock.set_open(false, cx);
|
||||
// }
|
||||
if panel.is_zoomed(cx) {
|
||||
dock.set_open(false, cx);
|
||||
}
|
||||
focus_center = true;
|
||||
}
|
||||
}
|
||||
|
@ -1654,6 +1659,7 @@ impl Workspace {
|
|||
self.left_dock.update(cx, |dock, cx| dock.zoom_out(cx));
|
||||
self.bottom_dock.update(cx, |dock, cx| dock.zoom_out(cx));
|
||||
self.right_dock.update(cx, |dock, cx| dock.zoom_out(cx));
|
||||
dbg!("Losing focus C");
|
||||
self.zoomed = None;
|
||||
self.zoomed_position = None;
|
||||
|
||||
|
@ -1697,6 +1703,7 @@ impl Workspace {
|
|||
}
|
||||
|
||||
if self.zoomed_position != dock_to_reveal {
|
||||
dbg!("losing D");
|
||||
self.zoomed = None;
|
||||
self.zoomed_position = None;
|
||||
}
|
||||
|
@ -1738,8 +1745,10 @@ impl Workspace {
|
|||
}
|
||||
|
||||
pub fn add_item(&mut self, item: Box<dyn ItemHandle>, cx: &mut ViewContext<Self>) {
|
||||
self.active_pane
|
||||
.update(cx, |pane, cx| pane.add_item(item, true, true, None, cx));
|
||||
self.active_pane.update(cx, |pane, cx| {
|
||||
dbg!(pane.items_len());
|
||||
pane.add_item(item, true, true, None, cx)
|
||||
});
|
||||
}
|
||||
|
||||
pub fn split_item(
|
||||
|
@ -2050,8 +2059,10 @@ impl Workspace {
|
|||
|
||||
self.dismiss_zoomed_items_to_reveal(None, cx);
|
||||
if pane.read(cx).is_zoomed() {
|
||||
dbg!("B");
|
||||
self.zoomed = Some(pane.downgrade().into());
|
||||
} else {
|
||||
dbg!("losing focus E");
|
||||
self.zoomed = None;
|
||||
}
|
||||
self.zoomed_position = None;
|
||||
|
@ -2102,6 +2113,7 @@ impl Workspace {
|
|||
if pane == self.active_pane {
|
||||
pane.update(cx, |pane, cx| pane.set_zoomed(true, cx));
|
||||
if pane.read(cx).has_focus(cx) {
|
||||
dbg!("A");
|
||||
self.zoomed = Some(pane.downgrade().into());
|
||||
self.zoomed_position = None;
|
||||
}
|
||||
|
@ -2111,6 +2123,7 @@ impl Workspace {
|
|||
pane::Event::ZoomOut => {
|
||||
pane.update(cx, |pane, cx| pane.set_zoomed(false, cx));
|
||||
if self.zoomed_position.is_none() {
|
||||
dbg!("losing focus F");
|
||||
self.zoomed = None;
|
||||
}
|
||||
cx.notify();
|
||||
|
@ -2233,6 +2246,7 @@ impl Workspace {
|
|||
}
|
||||
|
||||
fn remove_pane(&mut self, pane: View<Pane>, cx: &mut ViewContext<Self>) {
|
||||
dbg!("?????@@@@@@@@@@ remove pane");
|
||||
if self.center.remove(&pane).unwrap() {
|
||||
self.force_remove_pane(&pane, cx);
|
||||
self.unfollow(&pane, cx);
|
||||
|
@ -2241,8 +2255,14 @@ impl Workspace {
|
|||
self.panes_by_item.remove(&removed_item.item_id());
|
||||
}
|
||||
|
||||
dbg!("######### removed the pane", self.panes.len());
|
||||
// cx.focus_self();
|
||||
|
||||
cx.notify();
|
||||
} else {
|
||||
dbg!(
|
||||
"??????????? during pane removal, we decided to spare the pane and not removed it (main pane)"
|
||||
);
|
||||
self.active_item_path_changed(cx);
|
||||
}
|
||||
}
|
||||
|
@ -4400,9 +4420,12 @@ fn parse_pixel_size_env_var(value: &str) -> Option<Size<GlobalPixels>> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::item::{
|
||||
use crate::{
|
||||
dock::test::TestPanel,
|
||||
item::{
|
||||
test::{TestItem, TestProjectItem},
|
||||
ItemEvent,
|
||||
},
|
||||
};
|
||||
use fs::FakeFs;
|
||||
use gpui::TestAppContext;
|
||||
|
@ -4975,133 +4998,178 @@ mod tests {
|
|||
});
|
||||
}
|
||||
|
||||
// #[gpui::test]
|
||||
// async fn test_toggle_docks_and_panels(cx: &mut gpui::TestAppContext) {
|
||||
// init_test(cx);
|
||||
// let fs = FakeFs::new(cx.executor());
|
||||
#[gpui::test]
|
||||
async fn test_toggle_docks_and_panels(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx);
|
||||
let fs = FakeFs::new(cx.background_executor.clone());
|
||||
|
||||
// let project = Project::test(fs, [], cx).await;
|
||||
// let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
||||
// let workspace = window.root(cx);
|
||||
let project = Project::test(fs, [], cx).await;
|
||||
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
||||
let workspace = window.root(cx).unwrap();
|
||||
|
||||
// let panel = workspace.update(cx, |workspace, cx| {
|
||||
// let panel = cx.build_view(|_| TestPanel::new(DockPosition::Right));
|
||||
// workspace.add_panel(panel.clone(), cx);
|
||||
let panel = window
|
||||
.update(cx, |workspace, cx| {
|
||||
let (panel, right_dock) = {
|
||||
let panel = cx.build_view(|cx| TestPanel::new(DockPosition::Right, cx));
|
||||
workspace.add_panel(panel.clone(), cx);
|
||||
|
||||
// workspace
|
||||
// .right_dock()
|
||||
// .update(cx, |right_dock, cx| right_dock.set_open(true, cx));
|
||||
|
||||
// panel
|
||||
// });
|
||||
|
||||
// let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
||||
// pane.update(cx, |pane, cx| {
|
||||
// let item = cx.build_view(|_| TestItem::new(cx));
|
||||
// pane.add_item(Box::new(item), true, true, None, cx);
|
||||
// });
|
||||
|
||||
// // Transfer focus from center to panel
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
// });
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(workspace.right_dock().read(cx).is_open());
|
||||
(panel, workspace.right_dock().clone())
|
||||
};
|
||||
dbg!("A");
|
||||
right_dock.update(cx, |this, cx| this.set_open(true, cx));
|
||||
dbg!("B");
|
||||
panel
|
||||
})
|
||||
.unwrap();
|
||||
dbg!("C");
|
||||
let pane = cx
|
||||
.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, _| workspace.active_pane().clone())
|
||||
})
|
||||
.unwrap();
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
pane.update(cx, |pane, cx| {
|
||||
let item = cx.build_view(|cx| TestItem::new(cx));
|
||||
pane.add_item(Box::new(item), true, true, None, cx);
|
||||
})
|
||||
})
|
||||
.unwrap();
|
||||
// Transfer focus from center to panel
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(!panel.is_zoomed(cx));
|
||||
// assert!(panel.has_focus(cx));
|
||||
// });
|
||||
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
// // Transfer focus from panel to center
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
// });
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(workspace.right_dock().read(cx).is_open());
|
||||
// Transfer focus from panel to center
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
})
|
||||
});
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(!panel.is_zoomed(cx));
|
||||
// assert!(!panel.has_focus(cx));
|
||||
// });
|
||||
assert!(!panel.focus_handle(cx).is_focused(cx));
|
||||
})
|
||||
});
|
||||
|
||||
// // Close the dock
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_dock(DockPosition::Right, cx);
|
||||
// });
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(!workspace.right_dock().read(cx).is_open());
|
||||
// Close the dock
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_dock(DockPosition::Right, cx);
|
||||
})
|
||||
});
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(!workspace.right_dock().read(cx).is_open());
|
||||
// assert!(!panel.is_zoomed(cx));
|
||||
// assert!(!panel.has_focus(cx));
|
||||
// });
|
||||
assert!(!panel.focus_handle(cx).is_focused(cx));
|
||||
})
|
||||
});
|
||||
|
||||
// // Open the dock
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_dock(DockPosition::Right, cx);
|
||||
// });
|
||||
// Open the dock
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_dock(DockPosition::Right, cx);
|
||||
})
|
||||
});
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(workspace.right_dock().read(cx).is_open());
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(!panel.is_zoomed(cx));
|
||||
// assert!(panel.has_focus(cx));
|
||||
// });
|
||||
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||
})
|
||||
});
|
||||
|
||||
// // Focus and zoom panel
|
||||
// panel.update(cx, |panel, cx| {
|
||||
// cx.focus_self();
|
||||
// panel.set_zoomed(true, cx)
|
||||
// });
|
||||
// Focus and zoom panel
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
panel.update(cx, |panel, cx| {
|
||||
cx.focus_self();
|
||||
panel.set_zoomed(true, cx)
|
||||
})
|
||||
});
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(panel.is_zoomed(cx));
|
||||
// assert!(panel.has_focus(cx));
|
||||
// });
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(workspace.right_dock().read(cx).is_open());
|
||||
assert!(panel.is_zoomed(cx));
|
||||
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||
})
|
||||
});
|
||||
|
||||
// // Transfer focus to the center closes the dock
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
// });
|
||||
// Transfer focus to the center closes the dock
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
})
|
||||
});
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(!workspace.right_dock().read(cx).is_open());
|
||||
// assert!(panel.is_zoomed(cx));
|
||||
// assert!(!panel.has_focus(cx));
|
||||
// });
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(!workspace.right_dock().read(cx).is_open());
|
||||
assert!(panel.is_zoomed(cx));
|
||||
assert!(!panel.focus_handle(cx).is_focused(cx));
|
||||
})
|
||||
});
|
||||
|
||||
// // Transferring focus back to the panel keeps it zoomed
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
// });
|
||||
// Transferring focus back to the panel keeps it zoomed
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
});
|
||||
});
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(panel.is_zoomed(cx));
|
||||
// assert!(panel.has_focus(cx));
|
||||
// });
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(workspace.right_dock().read(cx).is_open());
|
||||
assert!(panel.is_zoomed(cx));
|
||||
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||
})
|
||||
});
|
||||
|
||||
// // Close the dock while it is zoomed
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_dock(DockPosition::Right, cx)
|
||||
// });
|
||||
// Close the dock while it is zoomed
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_dock(DockPosition::Right, cx)
|
||||
})
|
||||
});
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(!workspace.right_dock().read(cx).is_open());
|
||||
// assert!(panel.is_zoomed(cx));
|
||||
// assert!(workspace.zoomed.is_none());
|
||||
// assert!(!panel.has_focus(cx));
|
||||
// });
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(!workspace.right_dock().read(cx).is_open());
|
||||
assert!(panel.is_zoomed(cx));
|
||||
assert!(workspace.zoomed.is_none());
|
||||
assert!(!panel.focus_handle(cx).is_focused(cx));
|
||||
})
|
||||
});
|
||||
|
||||
// // Opening the dock, when it's zoomed, retains focus
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_dock(DockPosition::Right, cx)
|
||||
// });
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(panel.is_zoomed(cx));
|
||||
// assert!(workspace.zoomed.is_some());
|
||||
// assert!(panel.has_focus(cx));
|
||||
// });
|
||||
// Opening the dock, when it's zoomed, retains focus
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_dock(DockPosition::Right, cx)
|
||||
})
|
||||
});
|
||||
cx.executor().run_until_parked();
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(workspace.right_dock().read(cx).is_open());
|
||||
assert!(panel.is_zoomed(cx));
|
||||
assert!(workspace.zoomed.is_some());
|
||||
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||
})
|
||||
});
|
||||
|
||||
// // Unzoom and close the panel, zoom the active pane.
|
||||
// panel.update(cx, |panel, cx| panel.set_zoomed(false, cx));
|
||||
|
@ -5116,12 +5184,12 @@ mod tests {
|
|||
// });
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// let pane = pane.read(cx);
|
||||
// assert!(!pane.is_zoomed());
|
||||
// assert!(!pane.has_focus());
|
||||
// // assert!(!pane.is_zoomed());
|
||||
// assert!(!pane.focus_handle(cx).is_focused(cx));
|
||||
// assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(workspace.zoomed.is_none());
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
||||
// #[gpui::test]
|
||||
// async fn test_panels(cx: &mut gpui::TestAppContext) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue