Fix a todo in workspace
This commit is contained in:
parent
bed10b433a
commit
b7712c2f4b
2 changed files with 262 additions and 257 deletions
|
@ -9,8 +9,8 @@ use crate::{
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use collections::{HashMap, HashSet, VecDeque};
|
use collections::{HashMap, HashSet, VecDeque};
|
||||||
use gpui2::{
|
use gpui2::{
|
||||||
AppContext, AsyncWindowContext, Component, Div, EntityId, EventEmitter, Model, PromptLevel,
|
AppContext, AsyncWindowContext, Component, Div, EntityId, EventEmitter, FocusHandle, Model,
|
||||||
Render, Task, View, ViewContext, VisualContext, WeakView, WindowContext,
|
PromptLevel, Render, Task, View, ViewContext, VisualContext, WeakView, WindowContext,
|
||||||
};
|
};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use project2::{Project, ProjectEntryId, ProjectPath};
|
use project2::{Project, ProjectEntryId, ProjectPath};
|
||||||
|
@ -171,6 +171,7 @@ impl fmt::Debug for Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Pane {
|
pub struct Pane {
|
||||||
|
focus_handle: FocusHandle,
|
||||||
items: Vec<Box<dyn ItemHandle>>,
|
items: Vec<Box<dyn ItemHandle>>,
|
||||||
activation_history: Vec<EntityId>,
|
activation_history: Vec<EntityId>,
|
||||||
zoomed: bool,
|
zoomed: bool,
|
||||||
|
@ -183,7 +184,6 @@ pub struct Pane {
|
||||||
// tab_context_menu: ViewHandle<ContextMenu>,
|
// tab_context_menu: ViewHandle<ContextMenu>,
|
||||||
workspace: WeakView<Workspace>,
|
workspace: WeakView<Workspace>,
|
||||||
project: Model<Project>,
|
project: Model<Project>,
|
||||||
has_focus: bool,
|
|
||||||
// can_drop: Rc<dyn Fn(&DragAndDrop<Workspace>, &WindowContext) -> bool>,
|
// can_drop: Rc<dyn Fn(&DragAndDrop<Workspace>, &WindowContext) -> bool>,
|
||||||
// can_split: bool,
|
// can_split: bool,
|
||||||
// render_tab_bar_buttons: Rc<dyn Fn(&mut Pane, &mut ViewContext<Pane>) -> AnyElement<Pane>>,
|
// render_tab_bar_buttons: Rc<dyn Fn(&mut Pane, &mut ViewContext<Pane>) -> AnyElement<Pane>>,
|
||||||
|
@ -330,6 +330,7 @@ impl Pane {
|
||||||
|
|
||||||
let handle = cx.view().downgrade();
|
let handle = cx.view().downgrade();
|
||||||
Self {
|
Self {
|
||||||
|
focus_handle: cx.focus_handle(),
|
||||||
items: Vec::new(),
|
items: Vec::new(),
|
||||||
activation_history: Vec::new(),
|
activation_history: Vec::new(),
|
||||||
zoomed: false,
|
zoomed: false,
|
||||||
|
@ -353,7 +354,6 @@ impl Pane {
|
||||||
// tab_context_menu: cx.add_view(|cx| ContextMenu::new(pane_view_id, cx)),
|
// tab_context_menu: cx.add_view(|cx| ContextMenu::new(pane_view_id, cx)),
|
||||||
workspace,
|
workspace,
|
||||||
project,
|
project,
|
||||||
has_focus: false,
|
|
||||||
// can_drop: Rc::new(|_, _| true),
|
// can_drop: Rc::new(|_, _| true),
|
||||||
// can_split: true,
|
// can_split: true,
|
||||||
// render_tab_bar_buttons: Rc::new(move |pane, cx| {
|
// render_tab_bar_buttons: Rc::new(move |pane, cx| {
|
||||||
|
@ -420,8 +420,8 @@ impl Pane {
|
||||||
// &self.workspace
|
// &self.workspace
|
||||||
// }
|
// }
|
||||||
|
|
||||||
pub fn has_focus(&self) -> bool {
|
pub fn has_focus(&self, cx: &WindowContext) -> bool {
|
||||||
self.has_focus
|
self.focus_handle.contains_focused(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn active_item_index(&self) -> usize {
|
// pub fn active_item_index(&self) -> usize {
|
||||||
|
@ -1020,7 +1020,7 @@ impl Pane {
|
||||||
// to activating the item to the left
|
// to activating the item to the left
|
||||||
.unwrap_or_else(|| item_index.min(self.items.len()).saturating_sub(1));
|
.unwrap_or_else(|| item_index.min(self.items.len()).saturating_sub(1));
|
||||||
|
|
||||||
let should_activate = activate_pane || self.has_focus;
|
let should_activate = activate_pane || self.has_focus(cx);
|
||||||
self.activate_item(index_to_activate, should_activate, should_activate, cx);
|
self.activate_item(index_to_activate, should_activate, should_activate, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1184,6 +1184,10 @@ impl Pane {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn focus(&mut self, cx: &mut ViewContext<Pane>) {
|
||||||
|
cx.focus(&self.focus_handle);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn focus_active_item(&mut self, cx: &mut ViewContext<Self>) {
|
pub fn focus_active_item(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
if let Some(active_item) = self.active_item() {
|
if let Some(active_item) = self.active_item() {
|
||||||
let focus_handle = active_item.focus_handle(cx);
|
let focus_handle = active_item.focus_handle(cx);
|
||||||
|
@ -1865,14 +1869,14 @@ impl Pane {
|
||||||
// .into_any()
|
// .into_any()
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn set_zoomed(&mut self, zoomed: bool, cx: &mut ViewContext<Self>) {
|
pub fn set_zoomed(&mut self, zoomed: bool, cx: &mut ViewContext<Self>) {
|
||||||
// self.zoomed = zoomed;
|
self.zoomed = zoomed;
|
||||||
// cx.notify();
|
cx.notify();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn is_zoomed(&self) -> bool {
|
pub fn is_zoomed(&self) -> bool {
|
||||||
// self.zoomed
|
self.zoomed
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// impl Entity for Pane {
|
// impl Entity for Pane {
|
||||||
|
|
|
@ -26,7 +26,7 @@ use client2::{
|
||||||
proto::{self, PeerId},
|
proto::{self, PeerId},
|
||||||
Client, TypedEnvelope, UserStore,
|
Client, TypedEnvelope, UserStore,
|
||||||
};
|
};
|
||||||
use collections::{HashMap, HashSet};
|
use collections::{hash_map, HashMap, HashSet};
|
||||||
use dock::{Dock, DockPosition, PanelButtons};
|
use dock::{Dock, DockPosition, PanelButtons};
|
||||||
use futures::{
|
use futures::{
|
||||||
channel::{mpsc, oneshot},
|
channel::{mpsc, oneshot},
|
||||||
|
@ -35,10 +35,10 @@ use futures::{
|
||||||
};
|
};
|
||||||
use gpui2::{
|
use gpui2::{
|
||||||
div, point, size, AnyModel, AnyView, AnyWeakView, AppContext, AsyncAppContext,
|
div, point, size, AnyModel, AnyView, AnyWeakView, AppContext, AsyncAppContext,
|
||||||
AsyncWindowContext, Bounds, Component, Div, EntityId, EventEmitter, GlobalPixels, Model,
|
AsyncWindowContext, Bounds, Component, Div, Entity, EntityId, EventEmitter, FocusHandle,
|
||||||
ModelContext, ParentElement, Point, Render, Size, StatefulInteractive, Styled, Subscription,
|
GlobalPixels, Model, ModelContext, ParentElement, Point, Render, Size, StatefulInteractive,
|
||||||
Task, View, ViewContext, VisualContext, WeakView, WindowBounds, WindowContext, WindowHandle,
|
Styled, Subscription, Task, View, ViewContext, VisualContext, WeakView, WindowBounds,
|
||||||
WindowOptions,
|
WindowContext, WindowHandle, WindowOptions,
|
||||||
};
|
};
|
||||||
use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ItemSettings, ProjectItem};
|
use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ItemSettings, ProjectItem};
|
||||||
use language2::LanguageRegistry;
|
use language2::LanguageRegistry;
|
||||||
|
@ -547,9 +547,10 @@ pub enum Event {
|
||||||
|
|
||||||
pub struct Workspace {
|
pub struct Workspace {
|
||||||
weak_self: WeakView<Self>,
|
weak_self: WeakView<Self>,
|
||||||
|
focus_handle: FocusHandle,
|
||||||
// modal: Option<ActiveModal>,
|
// modal: Option<ActiveModal>,
|
||||||
zoomed: Option<AnyWeakView>,
|
zoomed: Option<AnyWeakView>,
|
||||||
// zoomed_position: Option<DockPosition>,
|
zoomed_position: Option<DockPosition>,
|
||||||
center: PaneGroup,
|
center: PaneGroup,
|
||||||
left_dock: View<Dock>,
|
left_dock: View<Dock>,
|
||||||
bottom_dock: View<Dock>,
|
bottom_dock: View<Dock>,
|
||||||
|
@ -766,9 +767,10 @@ impl Workspace {
|
||||||
cx.defer(|this, cx| this.update_window_title(cx));
|
cx.defer(|this, cx| this.update_window_title(cx));
|
||||||
Workspace {
|
Workspace {
|
||||||
weak_self: weak_handle.clone(),
|
weak_self: weak_handle.clone(),
|
||||||
|
focus_handle: cx.focus_handle(),
|
||||||
// modal: None,
|
// modal: None,
|
||||||
zoomed: None,
|
zoomed: None,
|
||||||
// zoomed_position: None,
|
zoomed_position: None,
|
||||||
center: PaneGroup::new(center_pane.clone()),
|
center: PaneGroup::new(center_pane.clone()),
|
||||||
panes: vec![center_pane.clone()],
|
panes: vec![center_pane.clone()],
|
||||||
panes_by_item: Default::default(),
|
panes_by_item: Default::default(),
|
||||||
|
@ -1699,9 +1701,9 @@ impl Workspace {
|
||||||
self.active_pane().read(cx).active_item()
|
self.active_pane().read(cx).active_item()
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn active_project_path(&self, cx: &ViewContext<Self>) -> Option<ProjectPath> {
|
fn active_project_path(&self, cx: &ViewContext<Self>) -> Option<ProjectPath> {
|
||||||
// self.active_item(cx).and_then(|item| item.project_path(cx))
|
self.active_item(cx).and_then(|item| item.project_path(cx))
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn save_active_item(
|
// pub fn save_active_item(
|
||||||
// &mut self,
|
// &mut self,
|
||||||
|
@ -1923,44 +1925,44 @@ impl Workspace {
|
||||||
// self.zoomed.and_then(|view| view.upgrade(cx))
|
// self.zoomed.and_then(|view| view.upgrade(cx))
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// fn dismiss_zoomed_items_to_reveal(
|
fn dismiss_zoomed_items_to_reveal(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// dock_to_reveal: Option<DockPosition>,
|
dock_to_reveal: Option<DockPosition>,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) {
|
) {
|
||||||
// // If a center pane is zoomed, unzoom it.
|
// If a center pane is zoomed, unzoom it.
|
||||||
// for pane in &self.panes {
|
for pane in &self.panes {
|
||||||
// if pane != &self.active_pane || dock_to_reveal.is_some() {
|
if pane != &self.active_pane || dock_to_reveal.is_some() {
|
||||||
// pane.update(cx, |pane, cx| pane.set_zoomed(false, cx));
|
pane.update(cx, |pane, cx| pane.set_zoomed(false, cx));
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // If another dock is zoomed, hide it.
|
// If another dock is zoomed, hide it.
|
||||||
// let mut focus_center = false;
|
let mut focus_center = false;
|
||||||
// for dock in [&self.left_dock, &self.right_dock, &self.bottom_dock] {
|
for dock in [&self.left_dock, &self.right_dock, &self.bottom_dock] {
|
||||||
// dock.update(cx, |dock, cx| {
|
dock.update(cx, |dock, cx| {
|
||||||
// if Some(dock.position()) != dock_to_reveal {
|
if Some(dock.position()) != dock_to_reveal {
|
||||||
// if let Some(panel) = dock.active_panel() {
|
if let Some(panel) = dock.active_panel() {
|
||||||
// if panel.is_zoomed(cx) {
|
if panel.is_zoomed(cx) {
|
||||||
// focus_center |= panel.has_focus(cx);
|
focus_center |= panel.has_focus(cx);
|
||||||
// dock.set_open(false, cx);
|
dock.set_open(false, cx);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if focus_center {
|
if focus_center {
|
||||||
// cx.focus_self();
|
cx.focus(&self.focus_handle);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if self.zoomed_position != dock_to_reveal {
|
if self.zoomed_position != dock_to_reveal {
|
||||||
// self.zoomed = None;
|
self.zoomed = None;
|
||||||
// self.zoomed_position = None;
|
self.zoomed_position = None;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// cx.notify();
|
cx.notify();
|
||||||
// }
|
}
|
||||||
|
|
||||||
fn add_pane(&mut self, _cx: &mut ViewContext<Self>) -> View<Pane> {
|
fn add_pane(&mut self, _cx: &mut ViewContext<Self>) -> View<Pane> {
|
||||||
todo!()
|
todo!()
|
||||||
|
@ -2288,214 +2290,213 @@ impl Workspace {
|
||||||
// self.center.pane_at_pixel_position(target)
|
// self.center.pane_at_pixel_position(target)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// 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>) {
|
||||||
// if self.active_pane != pane {
|
if self.active_pane != pane {
|
||||||
// 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);
|
||||||
// });
|
});
|
||||||
// self.active_item_path_changed(cx);
|
self.active_item_path_changed(cx);
|
||||||
// self.last_active_center_pane = Some(pane.downgrade());
|
self.last_active_center_pane = Some(pane.downgrade());
|
||||||
// }
|
}
|
||||||
|
|
||||||
// self.dismiss_zoomed_items_to_reveal(None, cx);
|
self.dismiss_zoomed_items_to_reveal(None, cx);
|
||||||
// if pane.read(cx).is_zoomed() {
|
if pane.read(cx).is_zoomed() {
|
||||||
// self.zoomed = Some(pane.downgrade().into_any());
|
self.zoomed = Some(pane.downgrade().into());
|
||||||
// } else {
|
} else {
|
||||||
// self.zoomed = None;
|
self.zoomed = None;
|
||||||
// }
|
}
|
||||||
// self.zoomed_position = None;
|
self.zoomed_position = None;
|
||||||
// self.update_active_view_for_followers(cx);
|
self.update_active_view_for_followers(cx);
|
||||||
|
|
||||||
// cx.notify();
|
cx.notify();
|
||||||
// }
|
}
|
||||||
|
|
||||||
fn handle_pane_event(
|
fn handle_pane_event(
|
||||||
&mut self,
|
&mut self,
|
||||||
_pane: View<Pane>,
|
pane: View<Pane>,
|
||||||
_event: &pane::Event,
|
event: &pane::Event,
|
||||||
_cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
todo!()
|
match event {
|
||||||
// match event {
|
pane::Event::AddItem { item } => item.added_to_pane(self, pane, cx),
|
||||||
// pane::Event::AddItem { item } => item.added_to_pane(self, pane, cx),
|
pane::Event::Split(direction) => {
|
||||||
// pane::Event::Split(direction) => {
|
self.split_and_clone(pane, *direction, cx);
|
||||||
// self.split_and_clone(pane, *direction, cx);
|
}
|
||||||
// }
|
pane::Event::Remove => self.remove_pane(pane, cx),
|
||||||
// pane::Event::Remove => self.remove_pane(pane, cx),
|
pane::Event::ActivateItem { local } => {
|
||||||
// pane::Event::ActivateItem { local } => {
|
if *local {
|
||||||
// if *local {
|
self.unfollow(&pane, cx);
|
||||||
// self.unfollow(&pane, cx);
|
}
|
||||||
// }
|
if &pane == self.active_pane() {
|
||||||
// if &pane == self.active_pane() {
|
self.active_item_path_changed(cx);
|
||||||
// self.active_item_path_changed(cx);
|
}
|
||||||
// }
|
}
|
||||||
// }
|
pane::Event::ChangeItemTitle => {
|
||||||
// pane::Event::ChangeItemTitle => {
|
if pane == self.active_pane {
|
||||||
// if pane == self.active_pane {
|
self.active_item_path_changed(cx);
|
||||||
// self.active_item_path_changed(cx);
|
}
|
||||||
// }
|
self.update_window_edited(cx);
|
||||||
// self.update_window_edited(cx);
|
}
|
||||||
// }
|
pane::Event::RemoveItem { item_id } => {
|
||||||
// pane::Event::RemoveItem { item_id } => {
|
self.update_window_edited(cx);
|
||||||
// self.update_window_edited(cx);
|
if let hash_map::Entry::Occupied(entry) = self.panes_by_item.entry(*item_id) {
|
||||||
// if let hash_map::Entry::Occupied(entry) = self.panes_by_item.entry(*item_id) {
|
if entry.get().entity_id() == pane.entity_id() {
|
||||||
// if entry.get().id() == pane.id() {
|
entry.remove();
|
||||||
// entry.remove();
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
pane::Event::Focus => {
|
||||||
// pane::Event::Focus => {
|
self.handle_pane_focused(pane.clone(), cx);
|
||||||
// self.handle_pane_focused(pane.clone(), cx);
|
}
|
||||||
// }
|
pane::Event::ZoomIn => {
|
||||||
// pane::Event::ZoomIn => {
|
if pane == self.active_pane {
|
||||||
// if pane == self.active_pane {
|
pane.update(cx, |pane, cx| pane.set_zoomed(true, cx));
|
||||||
// pane.update(cx, |pane, cx| pane.set_zoomed(true, cx));
|
if pane.read(cx).has_focus(cx) {
|
||||||
// if pane.read(cx).has_focus() {
|
self.zoomed = Some(pane.downgrade().into());
|
||||||
// self.zoomed = Some(pane.downgrade().into_any());
|
self.zoomed_position = None;
|
||||||
// self.zoomed_position = None;
|
}
|
||||||
// }
|
cx.notify();
|
||||||
// cx.notify();
|
}
|
||||||
// }
|
}
|
||||||
// }
|
pane::Event::ZoomOut => {
|
||||||
// pane::Event::ZoomOut => {
|
pane.update(cx, |pane, cx| pane.set_zoomed(false, cx));
|
||||||
// pane.update(cx, |pane, cx| pane.set_zoomed(false, cx));
|
if self.zoomed_position.is_none() {
|
||||||
// if self.zoomed_position.is_none() {
|
self.zoomed = None;
|
||||||
// self.zoomed = None;
|
}
|
||||||
// }
|
cx.notify();
|
||||||
// cx.notify();
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// self.serialize_workspace(cx);
|
self.serialize_workspace(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn split_pane(
|
pub fn split_pane(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// pane_to_split: View<Pane>,
|
pane_to_split: View<Pane>,
|
||||||
// split_direction: SplitDirection,
|
split_direction: SplitDirection,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) -> View<Pane> {
|
) -> View<Pane> {
|
||||||
// let new_pane = self.add_pane(cx);
|
let new_pane = self.add_pane(cx);
|
||||||
// self.center
|
self.center
|
||||||
// .split(&pane_to_split, &new_pane, split_direction)
|
.split(&pane_to_split, &new_pane, split_direction)
|
||||||
// .unwrap();
|
.unwrap();
|
||||||
// cx.notify();
|
cx.notify();
|
||||||
// new_pane
|
new_pane
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn split_and_clone(
|
pub fn split_and_clone(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// pane: View<Pane>,
|
pane: View<Pane>,
|
||||||
// direction: SplitDirection,
|
direction: SplitDirection,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) -> Option<View<Pane>> {
|
) -> Option<View<Pane>> {
|
||||||
// let item = pane.read(cx).active_item()?;
|
let item = pane.read(cx).active_item()?;
|
||||||
// let maybe_pane_handle = if let Some(clone) = item.clone_on_split(self.database_id(), cx) {
|
let maybe_pane_handle = if let Some(clone) = item.clone_on_split(self.database_id(), cx) {
|
||||||
// let new_pane = self.add_pane(cx);
|
let new_pane = self.add_pane(cx);
|
||||||
// new_pane.update(cx, |pane, cx| pane.add_item(clone, true, true, None, cx));
|
new_pane.update(cx, |pane, cx| pane.add_item(clone, true, true, None, cx));
|
||||||
// self.center.split(&pane, &new_pane, direction).unwrap();
|
self.center.split(&pane, &new_pane, direction).unwrap();
|
||||||
// Some(new_pane)
|
Some(new_pane)
|
||||||
// } else {
|
} else {
|
||||||
// None
|
None
|
||||||
// };
|
};
|
||||||
// cx.notify();
|
cx.notify();
|
||||||
// maybe_pane_handle
|
maybe_pane_handle
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn split_pane_with_item(
|
pub fn split_pane_with_item(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// pane_to_split: WeakView<Pane>,
|
pane_to_split: WeakView<Pane>,
|
||||||
// split_direction: SplitDirection,
|
split_direction: SplitDirection,
|
||||||
// from: WeakView<Pane>,
|
from: WeakView<Pane>,
|
||||||
// item_id_to_move: usize,
|
item_id_to_move: EntityId,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) {
|
) {
|
||||||
// let Some(pane_to_split) = pane_to_split.upgrade(cx) else {
|
let Some(pane_to_split) = pane_to_split.upgrade() else {
|
||||||
// return;
|
return;
|
||||||
// };
|
};
|
||||||
// let Some(from) = from.upgrade(cx) else {
|
let Some(from) = from.upgrade() else {
|
||||||
// return;
|
return;
|
||||||
// };
|
};
|
||||||
|
|
||||||
// let new_pane = self.add_pane(cx);
|
let new_pane = self.add_pane(cx);
|
||||||
// self.move_item(from.clone(), new_pane.clone(), item_id_to_move, 0, cx);
|
self.move_item(from.clone(), new_pane.clone(), item_id_to_move, 0, cx);
|
||||||
// self.center
|
self.center
|
||||||
// .split(&pane_to_split, &new_pane, split_direction)
|
.split(&pane_to_split, &new_pane, split_direction)
|
||||||
// .unwrap();
|
.unwrap();
|
||||||
// cx.notify();
|
cx.notify();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn split_pane_with_project_entry(
|
pub fn split_pane_with_project_entry(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// pane_to_split: WeakView<Pane>,
|
pane_to_split: WeakView<Pane>,
|
||||||
// split_direction: SplitDirection,
|
split_direction: SplitDirection,
|
||||||
// project_entry: ProjectEntryId,
|
project_entry: ProjectEntryId,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) -> Option<Task<Result<()>>> {
|
) -> Option<Task<Result<()>>> {
|
||||||
// let pane_to_split = pane_to_split.upgrade(cx)?;
|
let pane_to_split = pane_to_split.upgrade()?;
|
||||||
// let new_pane = self.add_pane(cx);
|
let new_pane = self.add_pane(cx);
|
||||||
// self.center
|
self.center
|
||||||
// .split(&pane_to_split, &new_pane, split_direction)
|
.split(&pane_to_split, &new_pane, split_direction)
|
||||||
// .unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// let path = self.project.read(cx).path_for_entry(project_entry, cx)?;
|
let path = self.project.read(cx).path_for_entry(project_entry, cx)?;
|
||||||
// let task = self.open_path(path, Some(new_pane.downgrade()), true, cx);
|
let task = self.open_path(path, Some(new_pane.downgrade()), true, cx);
|
||||||
// Some(cx.foreground().spawn(async move {
|
Some(cx.foreground_executor().spawn(async move {
|
||||||
// task.await?;
|
task.await?;
|
||||||
// Ok(())
|
Ok(())
|
||||||
// }))
|
}))
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn move_item(
|
pub fn move_item(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// source: View<Pane>,
|
source: View<Pane>,
|
||||||
// destination: View<Pane>,
|
destination: View<Pane>,
|
||||||
// item_id_to_move: usize,
|
item_id_to_move: EntityId,
|
||||||
// destination_index: usize,
|
destination_index: usize,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) {
|
) {
|
||||||
// let item_to_move = source
|
let item_to_move = source
|
||||||
// .read(cx)
|
.read(cx)
|
||||||
// .items()
|
.items()
|
||||||
// .enumerate()
|
.enumerate()
|
||||||
// .find(|(_, item_handle)| item_handle.id() == item_id_to_move);
|
.find(|(_, item_handle)| item_handle.id() == item_id_to_move);
|
||||||
|
|
||||||
// if item_to_move.is_none() {
|
if item_to_move.is_none() {
|
||||||
// log::warn!("Tried to move item handle which was not in `from` pane. Maybe tab was closed during drop");
|
log::warn!("Tried to move item handle which was not in `from` pane. Maybe tab was closed during drop");
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// let (item_ix, item_handle) = item_to_move.unwrap();
|
let (item_ix, item_handle) = item_to_move.unwrap();
|
||||||
// let item_handle = item_handle.clone();
|
let item_handle = item_handle.clone();
|
||||||
|
|
||||||
// if source != destination {
|
if source != destination {
|
||||||
// // Close item from previous pane
|
// Close item from previous pane
|
||||||
// source.update(cx, |source, cx| {
|
source.update(cx, |source, cx| {
|
||||||
// source.remove_item(item_ix, false, cx);
|
source.remove_item(item_ix, false, cx);
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // This automatically removes duplicate items in the pane
|
// This automatically removes duplicate items in the pane
|
||||||
// destination.update(cx, |destination, cx| {
|
destination.update(cx, |destination, cx| {
|
||||||
// destination.add_item(item_handle, true, true, Some(destination_index), cx);
|
destination.add_item(item_handle, true, true, Some(destination_index), cx);
|
||||||
// cx.focus_self();
|
destination.focus(cx)
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn remove_pane(&mut self, pane: View<Pane>, cx: &mut ViewContext<Self>) {
|
fn remove_pane(&mut self, pane: View<Pane>, cx: &mut ViewContext<Self>) {
|
||||||
// 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);
|
||||||
// self.last_leaders_by_pane.remove(&pane.downgrade());
|
self.last_leaders_by_pane.remove(&pane.downgrade());
|
||||||
// for removed_item in pane.read(cx).items() {
|
for removed_item in pane.read(cx).items() {
|
||||||
// self.panes_by_item.remove(&removed_item.id());
|
self.panes_by_item.remove(&removed_item.id());
|
||||||
// }
|
}
|
||||||
|
|
||||||
// cx.notify();
|
cx.notify();
|
||||||
// } else {
|
} else {
|
||||||
// self.active_item_path_changed(cx);
|
self.active_item_path_changed(cx);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
pub fn panes(&self) -> &[View<Pane>] {
|
pub fn panes(&self) -> &[View<Pane>] {
|
||||||
&self.panes
|
&self.panes
|
||||||
|
@ -2708,12 +2709,12 @@ impl Workspace {
|
||||||
.child("Collab title bar Item") // self.titlebar_item
|
.child("Collab title bar Item") // self.titlebar_item
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn active_item_path_changed(&mut self, cx: &mut ViewContext<Self>) {
|
fn active_item_path_changed(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
// let active_entry = self.active_project_path(cx);
|
let active_entry = self.active_project_path(cx);
|
||||||
// self.project
|
self.project
|
||||||
// .update(cx, |project, cx| project.set_active_path(active_entry, cx));
|
.update(cx, |project, cx| project.set_active_path(active_entry, cx));
|
||||||
// self.update_window_title(cx);
|
self.update_window_title(cx);
|
||||||
// }
|
}
|
||||||
|
|
||||||
fn update_window_title(&mut self, cx: &mut ViewContext<Self>) {
|
fn update_window_title(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
let project = self.project().read(cx);
|
let project = self.project().read(cx);
|
||||||
|
@ -3010,7 +3011,7 @@ impl Workspace {
|
||||||
fn update_active_view_for_followers(&mut self, cx: &mut ViewContext<Self>) {
|
fn update_active_view_for_followers(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
let mut is_project_item = true;
|
let mut is_project_item = true;
|
||||||
let mut update = proto::UpdateActiveView::default();
|
let mut update = proto::UpdateActiveView::default();
|
||||||
if self.active_pane.read(cx).has_focus() {
|
if self.active_pane.read(cx).has_focus(cx) {
|
||||||
let item = self
|
let item = self
|
||||||
.active_item(cx)
|
.active_item(cx)
|
||||||
.and_then(|item| item.to_followable_item_handle(cx));
|
.and_then(|item| item.to_followable_item_handle(cx));
|
||||||
|
@ -3105,7 +3106,7 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (pane, item) in items_to_activate {
|
for (pane, item) in items_to_activate {
|
||||||
let pane_was_focused = pane.read(cx).has_focus();
|
let pane_was_focused = pane.read(cx).has_focus(cx);
|
||||||
if let Some(index) = pane.update(cx, |pane, _| pane.index_for_item(item.as_ref())) {
|
if let Some(index) = pane.update(cx, |pane, _| pane.index_for_item(item.as_ref())) {
|
||||||
pane.update(cx, |pane, cx| pane.activate_item(index, false, false, cx));
|
pane.update(cx, |pane, cx| pane.activate_item(index, false, false, cx));
|
||||||
} else {
|
} else {
|
||||||
|
@ -3242,7 +3243,7 @@ impl Workspace {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
fn serialize_workspace(&self, cx: &mut ViewContext<Self>) {
|
fn serialize_workspace(&self, cx: &mut ViewContext<Self>) {
|
||||||
fn serialize_pane_handle(pane_handle: &View<Pane>, cx: &AppContext) -> SerializedPane {
|
fn serialize_pane_handle(pane_handle: &View<Pane>, cx: &WindowContext) -> SerializedPane {
|
||||||
let (items, active) = {
|
let (items, active) = {
|
||||||
let pane = pane_handle.read(cx);
|
let pane = pane_handle.read(cx);
|
||||||
let active_item_id = pane.active_item().map(|item| item.id());
|
let active_item_id = pane.active_item().map(|item| item.id());
|
||||||
|
@ -3256,7 +3257,7 @@ impl Workspace {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
pane.has_focus(),
|
pane.has_focus(cx),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3265,7 +3266,7 @@ impl Workspace {
|
||||||
|
|
||||||
fn build_serialized_pane_group(
|
fn build_serialized_pane_group(
|
||||||
pane_group: &Member,
|
pane_group: &Member,
|
||||||
cx: &AppContext,
|
cx: &WindowContext,
|
||||||
) -> SerializedPaneGroup {
|
) -> SerializedPaneGroup {
|
||||||
match pane_group {
|
match pane_group {
|
||||||
Member::Axis(PaneAxis {
|
Member::Axis(PaneAxis {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue