This commit is contained in:
K Simmons 2022-10-20 16:24:33 -07:00 committed by Mikayla Maki
parent 0c466f806c
commit 73f0459a0f
5 changed files with 25 additions and 21 deletions

View file

@ -14,6 +14,7 @@ use parking_lot::Mutex;
use rusqlite::Connection;
use migrations::MIGRATIONS;
pub use workspace::*;
#[derive(Clone)]
pub enum Db {

View file

@ -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 them

View file

@ -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,
}
}