zzz
This commit is contained in:
parent
5e3d0a6d03
commit
0fefe53773
4 changed files with 158 additions and 136 deletions
|
@ -214,13 +214,13 @@ impl TerminalPanel {
|
||||||
event: &pane::Event,
|
event: &pane::Event,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
match event {
|
match dbg!(event) {
|
||||||
pane::Event::ActivateItem { .. } => self.serialize(cx),
|
pane::Event::ActivateItem { .. } => self.serialize(cx),
|
||||||
pane::Event::RemoveItem { .. } => self.serialize(cx),
|
pane::Event::RemoveItem { .. } => self.serialize(cx),
|
||||||
pane::Event::Remove => cx.emit(PanelEvent::Close),
|
pane::Event::Remove => cx.emit(PanelEvent::Close),
|
||||||
pane::Event::ZoomIn => cx.emit(PanelEvent::ZoomIn),
|
pane::Event::ZoomIn => cx.emit(PanelEvent::ZoomIn),
|
||||||
pane::Event::ZoomOut => cx.emit(PanelEvent::ZoomOut),
|
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 } => {
|
pane::Event::AddItem { item } => {
|
||||||
if let Some(workspace) = self.workspace.upgrade() {
|
if let Some(workspace) = self.workspace.upgrade() {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::{status_bar::StatusItemView, Axis, Workspace};
|
use crate::{status_bar::StatusItemView, Axis, Workspace};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, px, Action, AnchorCorner, AnyView, AppContext, Div, Entity, EntityId, EventEmitter,
|
div, px, Action, AnchorCorner, AnyView, AppContext, Div, Entity, EntityId, EventEmitter,
|
||||||
FocusHandle, FocusableView, IntoElement, ParentElement, Render, SharedString, Styled,
|
FocusHandle, Focusable, FocusableView, IntoElement, ParentElement, Render, SharedString,
|
||||||
Subscription, View, ViewContext, VisualContext, WeakView, WindowContext,
|
Styled, Subscription, View, ViewContext, VisualContext, WeakView, WindowContext,
|
||||||
};
|
};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -10,6 +10,7 @@ use std::sync::Arc;
|
||||||
use ui::{h_stack, ContextMenu, IconButton, Tooltip};
|
use ui::{h_stack, ContextMenu, IconButton, Tooltip};
|
||||||
use ui::{prelude::*, right_click_menu};
|
use ui::{prelude::*, right_click_menu};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum PanelEvent {
|
pub enum PanelEvent {
|
||||||
ChangePosition,
|
ChangePosition,
|
||||||
ZoomIn,
|
ZoomIn,
|
||||||
|
|
|
@ -1493,7 +1493,7 @@ impl Pane {
|
||||||
.child(label);
|
.child(label);
|
||||||
|
|
||||||
right_click_menu(ix).trigger(tab).menu(|cx| {
|
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())
|
menu.action("Close", CloseActiveItem { save_intent: None }.boxed_clone())
|
||||||
.action("Close Others", CloseInactiveItems.boxed_clone())
|
.action("Close Others", CloseInactiveItems.boxed_clone())
|
||||||
.separator()
|
.separator()
|
||||||
|
@ -2057,13 +2057,13 @@ impl Render for Pane {
|
||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
.on_focus_in({
|
.on_focus_in({
|
||||||
let this = this.clone();
|
let this = this.clone();
|
||||||
move |event, cx| {
|
move |_, cx| {
|
||||||
this.update(cx, |this, cx| this.focus_in(cx)).ok();
|
this.update(cx, |this, cx| this.focus_in(cx)).ok();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on_focus_out({
|
.on_focus_out({
|
||||||
let this = this.clone();
|
let this = this.clone();
|
||||||
move |event, cx| {
|
move |_, cx| {
|
||||||
this.update(cx, |this, cx| this.focus_out(cx)).ok();
|
this.update(cx, |this, cx| this.focus_out(cx)).ok();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1558,6 +1558,7 @@ impl Workspace {
|
||||||
self.dismiss_zoomed_items_to_reveal(Some(dock_side), cx);
|
self.dismiss_zoomed_items_to_reveal(Some(dock_side), cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbg!("~~~~~~~~~~~~ ???????", focus_center);
|
||||||
if focus_center {
|
if focus_center {
|
||||||
self.active_pane.update(cx, |pane, cx| pane.focus(cx))
|
self.active_pane.update(cx, |pane, cx| pane.focus(cx))
|
||||||
}
|
}
|
||||||
|
@ -1738,8 +1739,10 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_item(&mut self, item: Box<dyn ItemHandle>, cx: &mut ViewContext<Self>) {
|
pub fn add_item(&mut self, item: Box<dyn ItemHandle>, cx: &mut ViewContext<Self>) {
|
||||||
self.active_pane
|
self.active_pane.update(cx, |pane, cx| {
|
||||||
.update(cx, |pane, cx| pane.add_item(item, true, true, None, cx));
|
dbg!(pane.items_len());
|
||||||
|
pane.add_item(item, true, true, None, cx)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn split_item(
|
pub fn split_item(
|
||||||
|
@ -2039,7 +2042,14 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_pane_focused(&mut self, pane: View<Pane>, cx: &mut ViewContext<Self>) {
|
fn handle_pane_focused(&mut self, pane: View<Pane>, cx: &mut ViewContext<Self>) {
|
||||||
|
// TODO kb remove
|
||||||
|
eprintln!(
|
||||||
|
"########## handle_pane_focused acrive: {}, new: {}",
|
||||||
|
self.active_pane.read(cx).items_len(),
|
||||||
|
pane.read(cx).items_len()
|
||||||
|
);
|
||||||
if self.active_pane != pane {
|
if self.active_pane != pane {
|
||||||
|
dbg!("########## got new pane to activate",);
|
||||||
self.active_pane = pane.clone();
|
self.active_pane = pane.clone();
|
||||||
self.status_bar.update(cx, |status_bar, cx| {
|
self.status_bar.update(cx, |status_bar, cx| {
|
||||||
status_bar.set_active_pane(&self.active_pane, cx);
|
status_bar.set_active_pane(&self.active_pane, cx);
|
||||||
|
@ -2233,6 +2243,7 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_pane(&mut self, pane: View<Pane>, cx: &mut ViewContext<Self>) {
|
fn remove_pane(&mut self, pane: View<Pane>, cx: &mut ViewContext<Self>) {
|
||||||
|
dbg!("?????@@@@@@@@@@ remove pane");
|
||||||
if self.center.remove(&pane).unwrap() {
|
if self.center.remove(&pane).unwrap() {
|
||||||
self.force_remove_pane(&pane, cx);
|
self.force_remove_pane(&pane, cx);
|
||||||
self.unfollow(&pane, cx);
|
self.unfollow(&pane, cx);
|
||||||
|
@ -2241,8 +2252,14 @@ impl Workspace {
|
||||||
self.panes_by_item.remove(&removed_item.item_id());
|
self.panes_by_item.remove(&removed_item.item_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbg!("######### removed the pane", self.panes.len());
|
||||||
|
// cx.focus_self();
|
||||||
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
} else {
|
} else {
|
||||||
|
dbg!(
|
||||||
|
"??????????? during pane removal, we decided to spare the pane and not removed it (main pane)"
|
||||||
|
);
|
||||||
self.active_item_path_changed(cx);
|
self.active_item_path_changed(cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4400,9 +4417,12 @@ fn parse_pixel_size_env_var(value: &str) -> Option<Size<GlobalPixels>> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::item::{
|
use crate::{
|
||||||
test::{TestItem, TestProjectItem},
|
dock::test::TestPanel,
|
||||||
ItemEvent,
|
item::{
|
||||||
|
test::{TestItem, TestProjectItem},
|
||||||
|
ItemEvent,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use fs::FakeFs;
|
use fs::FakeFs;
|
||||||
use gpui::TestAppContext;
|
use gpui::TestAppContext;
|
||||||
|
@ -4975,153 +4995,154 @@ mod tests {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[gpui::test]
|
#[gpui::test]
|
||||||
// async fn test_toggle_docks_and_panels(cx: &mut gpui::TestAppContext) {
|
async fn test_toggle_docks_and_panels(cx: &mut gpui::TestAppContext) {
|
||||||
// init_test(cx);
|
init_test(cx);
|
||||||
// let fs = FakeFs::new(cx.executor());
|
let fs = FakeFs::new(cx.background_executor.clone());
|
||||||
|
|
||||||
// let project = Project::test(fs, [], cx).await;
|
let project = Project::test(fs, [], cx).await;
|
||||||
// let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
||||||
// let workspace = window.root(cx);
|
let workspace = window.root(cx).unwrap();
|
||||||
|
|
||||||
// let panel = workspace.update(cx, |workspace, cx| {
|
cx.update_window(window.into(), |_, cx| {
|
||||||
// let panel = cx.build_view(|_| TestPanel::new(DockPosition::Right));
|
let panel = workspace.update(cx, |workspace, cx| {
|
||||||
// workspace.add_panel(panel.clone(), cx);
|
let panel = cx.build_view(|cx| TestPanel::new(DockPosition::Right, cx));
|
||||||
|
workspace.add_panel(panel.clone(), cx);
|
||||||
|
|
||||||
// workspace
|
workspace
|
||||||
// .right_dock()
|
.right_dock()
|
||||||
// .update(cx, |right_dock, cx| right_dock.set_open(true, cx));
|
.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(|cx| TestItem::new(cx));
|
||||||
|
pane.add_item(Box::new(item), true, true, None, cx);
|
||||||
|
});
|
||||||
|
|
||||||
// panel
|
// Transfer focus from center to panel
|
||||||
// });
|
workspace.update(cx, |workspace, cx| {
|
||||||
|
workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||||
|
});
|
||||||
|
|
||||||
// let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
workspace.update(cx, |workspace, cx| {
|
||||||
// pane.update(cx, |pane, cx| {
|
assert!(workspace.right_dock().read(cx).is_open());
|
||||||
// let item = cx.build_view(|_| TestItem::new(cx));
|
// assert!(!panel.is_zoomed(cx));
|
||||||
// pane.add_item(Box::new(item), true, true, None, cx);
|
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||||
// });
|
});
|
||||||
|
|
||||||
// // Transfer focus from center to panel
|
// Transfer focus from panel to center
|
||||||
// workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// workspace.toggle_panel_focus::<TestPanel>(cx);
|
workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// assert!(workspace.right_dock().read(cx).is_open());
|
assert!(workspace.right_dock().read(cx).is_open());
|
||||||
// assert!(!panel.is_zoomed(cx));
|
// assert!(!panel.is_zoomed(cx));
|
||||||
// assert!(panel.has_focus(cx));
|
assert!(!panel.focus_handle(cx).is_focused(cx));
|
||||||
// });
|
});
|
||||||
|
|
||||||
// // Transfer focus from panel to center
|
// Close the dock
|
||||||
// workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// workspace.toggle_panel_focus::<TestPanel>(cx);
|
workspace.toggle_dock(DockPosition::Right, cx);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// assert!(workspace.right_dock().read(cx).is_open());
|
assert!(!workspace.right_dock().read(cx).is_open());
|
||||||
// assert!(!panel.is_zoomed(cx));
|
// assert!(!panel.is_zoomed(cx));
|
||||||
// assert!(!panel.has_focus(cx));
|
assert!(!panel.focus_handle(cx).is_focused(cx));
|
||||||
// });
|
});
|
||||||
|
|
||||||
// // Close the dock
|
// Open the dock
|
||||||
// workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// workspace.toggle_dock(DockPosition::Right, cx);
|
workspace.toggle_dock(DockPosition::Right, cx);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// assert!(!workspace.right_dock().read(cx).is_open());
|
assert!(workspace.right_dock().read(cx).is_open());
|
||||||
// assert!(!panel.is_zoomed(cx));
|
// assert!(!panel.is_zoomed(cx));
|
||||||
// assert!(!panel.has_focus(cx));
|
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||||
// });
|
});
|
||||||
|
|
||||||
// // Open the dock
|
// Focus and zoom panel
|
||||||
// workspace.update(cx, |workspace, cx| {
|
panel.update(cx, |panel, cx| {
|
||||||
// workspace.toggle_dock(DockPosition::Right, cx);
|
cx.focus_self();
|
||||||
// });
|
panel.set_zoomed(true, cx)
|
||||||
|
});
|
||||||
|
|
||||||
// workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// assert!(workspace.right_dock().read(cx).is_open());
|
assert!(workspace.right_dock().read(cx).is_open());
|
||||||
// assert!(!panel.is_zoomed(cx));
|
assert!(panel.is_zoomed(cx));
|
||||||
// assert!(panel.has_focus(cx));
|
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||||
// });
|
});
|
||||||
|
|
||||||
// // Focus and zoom panel
|
// Transfer focus to the center closes the dock
|
||||||
// panel.update(cx, |panel, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// cx.focus_self();
|
workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||||
// panel.set_zoomed(true, cx)
|
});
|
||||||
// });
|
|
||||||
|
|
||||||
// workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// assert!(workspace.right_dock().read(cx).is_open());
|
assert!(!workspace.right_dock().read(cx).is_open());
|
||||||
// assert!(panel.is_zoomed(cx));
|
assert!(panel.is_zoomed(cx));
|
||||||
// assert!(panel.has_focus(cx));
|
assert!(!panel.focus_handle(cx).is_focused(cx));
|
||||||
// });
|
});
|
||||||
|
|
||||||
// // Transfer focus to the center closes the dock
|
// Transferring focus back to the panel keeps it zoomed
|
||||||
// workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// workspace.toggle_panel_focus::<TestPanel>(cx);
|
workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// assert!(!workspace.right_dock().read(cx).is_open());
|
assert!(workspace.right_dock().read(cx).is_open());
|
||||||
// assert!(panel.is_zoomed(cx));
|
assert!(panel.is_zoomed(cx));
|
||||||
// assert!(!panel.has_focus(cx));
|
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||||
// });
|
});
|
||||||
|
|
||||||
// // Transferring focus back to the panel keeps it zoomed
|
// Close the dock while it is zoomed
|
||||||
// workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// workspace.toggle_panel_focus::<TestPanel>(cx);
|
workspace.toggle_dock(DockPosition::Right, cx)
|
||||||
// });
|
});
|
||||||
|
|
||||||
// workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// assert!(workspace.right_dock().read(cx).is_open());
|
assert!(!workspace.right_dock().read(cx).is_open());
|
||||||
// assert!(panel.is_zoomed(cx));
|
assert!(panel.is_zoomed(cx));
|
||||||
// assert!(panel.has_focus(cx));
|
assert!(workspace.zoomed.is_none());
|
||||||
// });
|
assert!(!panel.focus_handle(cx).is_focused(cx));
|
||||||
|
});
|
||||||
|
|
||||||
// // Close the dock while it is zoomed
|
// Opening the dock, when it's zoomed, retains focus
|
||||||
// workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// workspace.toggle_dock(DockPosition::Right, cx)
|
workspace.toggle_dock(DockPosition::Right, cx)
|
||||||
// });
|
});
|
||||||
|
|
||||||
// workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// assert!(!workspace.right_dock().read(cx).is_open());
|
assert!(workspace.right_dock().read(cx).is_open());
|
||||||
// assert!(panel.is_zoomed(cx));
|
assert!(panel.is_zoomed(cx));
|
||||||
// assert!(workspace.zoomed.is_none());
|
assert!(workspace.zoomed.is_some());
|
||||||
// assert!(!panel.has_focus(cx));
|
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||||
// });
|
});
|
||||||
|
|
||||||
// // Opening the dock, when it's zoomed, retains focus
|
// Unzoom and close the panel, zoom the active pane.
|
||||||
// workspace.update(cx, |workspace, cx| {
|
panel.update(cx, |panel, cx| panel.set_zoomed(false, cx));
|
||||||
// workspace.toggle_dock(DockPosition::Right, cx)
|
workspace.update(cx, |workspace, cx| {
|
||||||
// });
|
workspace.toggle_dock(DockPosition::Right, cx)
|
||||||
|
});
|
||||||
|
pane.update(cx, |pane, cx| pane.toggle_zoom(&Default::default(), cx));
|
||||||
|
|
||||||
// workspace.update(cx, |workspace, cx| {
|
// Opening a dock unzooms the pane.
|
||||||
// assert!(workspace.right_dock().read(cx).is_open());
|
workspace.update(cx, |workspace, cx| {
|
||||||
// assert!(panel.is_zoomed(cx));
|
workspace.toggle_dock(DockPosition::Right, cx)
|
||||||
// assert!(workspace.zoomed.is_some());
|
});
|
||||||
// assert!(panel.has_focus(cx));
|
workspace.update(cx, |workspace, cx| {
|
||||||
// });
|
let pane = pane.read(cx);
|
||||||
|
// assert!(!pane.is_zoomed());
|
||||||
// // Unzoom and close the panel, zoom the active pane.
|
assert!(!pane.focus_handle(cx).is_focused(cx));
|
||||||
// panel.update(cx, |panel, cx| panel.set_zoomed(false, cx));
|
assert!(workspace.right_dock().read(cx).is_open());
|
||||||
// workspace.update(cx, |workspace, cx| {
|
assert!(workspace.zoomed.is_none());
|
||||||
// workspace.toggle_dock(DockPosition::Right, cx)
|
});
|
||||||
// });
|
})
|
||||||
// pane.update(cx, |pane, cx| pane.toggle_zoom(&Default::default(), cx));
|
.unwrap();
|
||||||
|
}
|
||||||
// // Opening a dock unzooms the pane.
|
|
||||||
// workspace.update(cx, |workspace, cx| {
|
|
||||||
// workspace.toggle_dock(DockPosition::Right, cx)
|
|
||||||
// });
|
|
||||||
// workspace.update(cx, |workspace, cx| {
|
|
||||||
// let pane = pane.read(cx);
|
|
||||||
// assert!(!pane.is_zoomed());
|
|
||||||
// assert!(!pane.has_focus());
|
|
||||||
// assert!(workspace.right_dock().read(cx).is_open());
|
|
||||||
// assert!(workspace.zoomed.is_none());
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[gpui::test]
|
// #[gpui::test]
|
||||||
// async fn test_panels(cx: &mut gpui::TestAppContext) {
|
// async fn test_panels(cx: &mut gpui::TestAppContext) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue