Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
wip
K Simmons73f0459a0fad
diff --git a/crates/db/src/db.rs b/crates/db/src/db.rsindex bf3cd645089..9a649869878 100644--- a/crates/db/src/db.rs+++ b/crates/db/src/db.rs@@ -14,6 +14,7 @@ use parking_lot::Mutex;use rusqlite::Connection;use migrations::MIGRATIONS;+pub use workspace::*;#[derive(Clone)]pub enum Db {diff --git a/crates/db/src/pane.rs b/crates/db/src/pane.rsindex 98feb36abf6..8ca1fd5de22 100644--- a/crates/db/src/pane.rs+++ b/crates/db/src/pane.rs@@ -30,13 +30,13 @@ CREATE TABLE pane_items() STRICT;";-#[derive(Debug, PartialEq, Eq)]+#[derive(Debug, PartialEq, Eq, Copy, Clone)]pub struct PaneId {workspace_id: WorkspaceId,pane_id: usize,}-#[derive(Debug, PartialEq, Eq)]+#[derive(Debug, PartialEq, Eq, Copy, Clone)]pub struct PaneGroupId {workspace_id: WorkspaceId,group_id: usize,@@ -58,6 +58,16 @@ pub struct SerializedPaneGroup {children: Vec<PaneGroupChild>,}+impl SerializedPaneGroup {+ pub(crate) fn empty_root(workspace_id: WorkspaceId) -> Self {+ Self {+ group_id: PaneGroupId::root(workspace_id),+ axis: Default::default(),+ children: Default::default(),+ }+ }+}+struct PaneGroupChildRow {child_pane_id: Option<usize>,child_group_id: Option<usize>,@@ -99,7 +109,7 @@ impl Db {));}}- children.sort_by_key(|(index, _)| index);+ children.sort_by_key(|(index, _)| *index);SerializedPaneGroup {group_id: pane_group_id,@@ -108,18 +118,18 @@ impl Db {}}- pub fn get_pane_group_children(+ fn get_pane_group_children(&self,pane_group_id: PaneGroupId,) -> impl Iterator<Item = PaneGroupChildRow> {- unimplemented!()+ Vec::new().into_iter()}- pub fn get_pane_group_axis(&self, pane_group_id: PaneGroupId) -> Axis {+ fn get_pane_group_axis(&self, pane_group_id: PaneGroupId) -> Axis {unimplemented!();}- pub fn save_center_pane_group(&self, center_pane_group: SerializedPaneGroup) {+ pub fn save_pane_splits(&self, center_pane_group: SerializedPaneGroup) {// Delete the center pane group for this workspace and any of its children// Generate new pane group IDs as we go through// insert themdiff --git a/crates/db/src/workspace.rs b/crates/db/src/workspace.rsindex e342391b715..e60cb19e3bc 100644--- a/crates/db/src/workspace.rs+++ b/crates/db/src/workspace.rs@@ -36,7 +36,6 @@ CREATE TABLE worktree_roots(pub struct WorkspaceId(usize);struct WorkspaceRow {- pub workspace_id: WorkspaceId,pub center_group_id: PaneGroupId,pub dock_pane_id: PaneId,}@@ -67,15 +66,10 @@ impl Db {}} else {let workspace_id = self.get_next_workspace_id();- let center_group = SerializedPaneGroup {- group_id: PaneGroupId::root(workspace_id),- axis: Default::default(),- children: Default::default(),- };SerializedWorkspace {workspace_id,- center_group,+ center_group: SerializedPaneGroup::empty_root(workspace_id),dock_pane: None,}}diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rsindex fa8f182a316..699b9b1d601 100644--- a/crates/workspace/src/dock.rs+++ b/crates/workspace/src/dock.rs@@ -137,11 +137,7 @@ pub struct Dock {}impl Dock {- pub fn new(- serialized_pane: SerializedPane,- default_item_factory: DefaultItemFactory,- cx: &mut ViewContext<Workspace>,- ) -> Self {+ pub fn new(default_item_factory: DefaultItemFactory, cx: &mut ViewContext<Workspace>) -> Self {let anchor = cx.global::<Settings>().default_dock_anchor;let pane = cx.add_view(|cx| Pane::new(Some(anchor), cx));pane.update(cx, |pane, cx| {diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex 86eff8fb799..154cf109129 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -15,6 +15,7 @@ use anyhow::{anyhow, Context, Result};use call::ActiveCall;use client::{proto, Client, PeerId, TypedEnvelope, UserStore};use collections::{hash_map, HashMap, HashSet};+use db::{SerializedWorkspace, WorkspaceId};use dock::{DefaultItemFactory, Dock, ToggleDockButton};use drag_and_drop::DragAndDrop;use fs::{self, Fs};@@ -1064,6 +1065,7 @@ pub enum Event {pub struct Workspace {weak_self: WeakViewHandle<Self>,+ db_id: WorkspaceId,client: Arc<Client>,user_store: ModelHandle<client::UserStore>,remote_entity_subscription: Option<client::Subscription>,@@ -1110,8 +1112,8 @@ enum FollowerItem {impl Workspace {pub fn new(- serialized_workspace: SerializedWorkspace,project: ModelHandle<Project>,+ serialized_workspace: SerializedWorkspace,dock_default_factory: DefaultItemFactory,cx: &mut ViewContext<Self>,) -> Self {@@ -1175,7 +1177,7 @@ impl Workspace {cx.emit_global(WorkspaceCreated(weak_handle.clone()));- let dock = Dock::new(cx, dock_default_factory);+ let dock = Dock::new(dock_default_factory, cx);let dock_pane = dock.pane().clone();let left_sidebar = cx.add_view(|_| Sidebar::new(SidebarSide::Left));@@ -1207,6 +1209,7 @@ impl Workspace {let mut this = Workspace {modal: None,weak_self: weak_handle,+ db_id: serialized_workspace.workspace_id,center: PaneGroup::new(center_pane.clone()),dock,// When removing an item, the last element remaining in this array