Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Got Zed compiling again 🥰
Mikayla Maki6b214acbc4f3
diff --git a/crates/db/examples/serialize-pane.rs b/crates/db/examples/serialize-pane.rsindex ebe88037cd2..2f362fb9972 100644--- a/crates/db/examples/serialize-pane.rs+++ b/crates/db/examples/serialize-pane.rs@@ -1,7 +1,5 @@use std::{fs::File, path::Path};-use db::{pane::SerializedDockPane, DockAnchor};-const TEST_FILE: &'static str = "test-db.db";fn main() -> anyhow::Result<()> {@@ -14,31 +12,31 @@ fn main() -> anyhow::Result<()> {let f = File::create(file)?;drop(f);- let workspace_1 = db.workspace_for_roots(&["/tmp"]);- let workspace_2 = db.workspace_for_roots(&["/tmp", "/tmp2"]);- let workspace_3 = db.workspace_for_roots(&["/tmp3", "/tmp2"]);-- db.save_dock_pane(- &workspace_1.workspace_id,- &SerializedDockPane {- anchor_position: DockAnchor::Expanded,- visible: true,- },- );- db.save_dock_pane(- &workspace_2.workspace_id,- &SerializedDockPane {- anchor_position: DockAnchor::Bottom,- visible: true,- },- );- db.save_dock_pane(- &workspace_3.workspace_id,- &SerializedDockPane {- anchor_position: DockAnchor::Right,- visible: false,- },- );+ // let workspace_1 = db.workspace_for_roots(&["/tmp"]);+ // let workspace_2 = db.workspace_for_roots(&["/tmp", "/tmp2"]);+ // let workspace_3 = db.workspace_for_roots(&["/tmp3", "/tmp2"]);++ // db.save_dock_pane(+ // &workspace_1.workspace_id,+ // &SerializedDockPane {+ // anchor_position: DockAnchor::Expanded,+ // visible: true,+ // },+ // );+ // db.save_dock_pane(+ // &workspace_2.workspace_id,+ // &SerializedDockPane {+ // anchor_position: DockAnchor::Bottom,+ // visible: true,+ // },+ // );+ // db.save_dock_pane(+ // &workspace_3.workspace_id,+ // &SerializedDockPane {+ // anchor_position: DockAnchor::Right,+ // visible: false,+ // },+ // );db.write_to(file).ok();diff --git a/crates/db/src/workspace.rs b/crates/db/src/workspace.rsindex 5fc9e075e97..cf09bdd06eb 100644--- a/crates/db/src/workspace.rs+++ b/crates/db/src/workspace.rs@@ -2,7 +2,7 @@ mod items;pub mod model;pub(crate) mod pane;-use anyhow::{Context, Result};+use anyhow::Context;use util::{iife, ResultExt};use std::path::{Path, PathBuf};@@ -10,9 +10,6 @@ use std::path::{Path, PathBuf};use indoc::indoc;use sqlez::migrations::Migration;-// If you need to debug the worktree root code, change 'BLOB' here to 'TEXT' for easier debugging-// you might want to update some of the parsing code as well, I've left the variations in but commented-// out. This will panic if run on an existing db that has already been migratedpub(crate) const WORKSPACES_MIGRATION: Migration = Migration::new("workspace",&[indoc! {"@@ -39,7 +36,9 @@ impl Db {) -> Option<SerializedWorkspace> {let workspace_id: WorkspaceId = worktree_roots.into();- let (_, dock_anchor, dock_visible) = iife!({+ // Note that we re-assign the workspace_id here in case it's empty+ // and we've grabbed the most recent workspace+ let (workspace_id, dock_anchor, dock_visible) = iife!({if worktree_roots.len() == 0 {self.prepare(indoc! {"SELECT workspace_id, dock_anchor, dock_visible@@ -51,7 +50,7 @@ impl Db {SELECT workspace_id, dock_anchor, dock_visibleFROM workspacesWHERE workspace_id = ?"})?- .with_bindings(workspace_id)?+ .with_bindings(&workspace_id)?.maybe_row::<WorkspaceRow>()}})@@ -59,8 +58,8 @@ impl Db {.flatten()?;Some(SerializedWorkspace {- dock_pane: self.get_dock_pane(workspace_id)?,- center_group: self.get_center_group(workspace_id),+ dock_pane: self.get_dock_pane(&workspace_id)?,+ center_group: self.get_center_group(&workspace_id),dock_anchor,dock_visible,})@@ -82,12 +81,12 @@ impl Db {self.prepare(indoc!{"DELETE FROM workspaces WHERE workspace_id = ?1;INSERT INTO workspaces(workspace_id, dock_anchor, dock_visible) VALUES (?1, ?, ?)"})?- .with_bindings((workspace_id, workspace.dock_anchor, workspace.dock_visible))?+ .with_bindings((&workspace_id, workspace.dock_anchor, workspace.dock_visible))?.exec()?;// Save center pane group and dock pane- Self::save_center_group(workspace_id, &workspace.center_group, conn)?;- Self::save_dock_pane(workspace_id, &workspace.dock_pane, conn)?;+ Self::save_center_group(&workspace_id, &workspace.center_group, conn)?;+ Self::save_dock_pane(&workspace_id, &workspace.dock_pane, conn)?;Ok(())})@@ -98,11 +97,12 @@ impl Db {/// Returns the previous workspace ids sorted by last modified along with their opened worktree rootspub fn recent_workspaces(&self, limit: usize) -> Vec<Vec<PathBuf>> {iife!({- self.prepare("SELECT workspace_id FROM workspaces ORDER BY timestamp DESC LIMIT ?")?+ Ok::<_, anyhow::Error>(self.prepare("SELECT workspace_id FROM workspaces ORDER BY timestamp DESC LIMIT ?")?.with_bindings(limit)?.rows::<WorkspaceId>()?.into_iter().map(|id| id.0)- .collect()+ .collect::<Vec<Vec<PathBuf>>>())+}).log_err().unwrap_or_default()}}diff --git a/crates/db/src/workspace/model.rs b/crates/db/src/workspace/model.rsindex 37c353a47b6..1a6b4ee41f2 100644--- a/crates/db/src/workspace/model.rs+++ b/crates/db/src/workspace/model.rs@@ -9,7 +9,7 @@ use sqlez::{};#[derive(Debug, PartialEq, Eq, Clone)]-pub(crate) struct WorkspaceId(Vec<PathBuf>);+pub(crate) struct WorkspaceId(pub(crate) Vec<PathBuf>);impl<P: AsRef<Path>, T: IntoIterator<Item = P>> From<T> for WorkspaceId {fn from(iterator: T) -> Self {@@ -22,7 +22,7 @@ impl<P: AsRef<Path>, T: IntoIterator<Item = P>> From<T> for WorkspaceId {}}-impl Bind for WorkspaceId {+impl Bind for &WorkspaceId {fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {bincode::serialize(&self.0).expect("Bincode serialization of paths should not fail")@@ -85,13 +85,16 @@ pub struct SerializedWorkspace {#[derive(Debug, PartialEq, Eq)]pub struct SerializedPaneGroup {axis: Axis,- children: Vec<PaneGroupChild>,+ children: Vec<SerializedPaneGroup>,}+#[derive(Debug)]pub struct SerializedPane {- children: Vec<SerializedItem>,+ _children: Vec<SerializedItem>,}+#[derive(Debug)]pub enum SerializedItemKind {}+#[derive(Debug)]pub enum SerializedItem {}diff --git a/crates/db/src/workspace/pane.rs b/crates/db/src/workspace/pane.rsindex 4f263e496c7..73306707cfc 100644--- a/crates/db/src/workspace/pane.rs+++ b/crates/db/src/workspace/pane.rs@@ -1,10 +1,11 @@-use gpui::Axis;+use anyhow::Result;use indoc::indoc;use sqlez::{connection::Connection, migrations::Migration};-use util::{iife, ResultExt};++use crate::model::SerializedPane;use super::{- model::{PaneGroupId, PaneId, SerializedDockPane, SerializedPaneGroup, WorkspaceId},+ model::{SerializedPaneGroup, WorkspaceId},Db,};@@ -44,11 +45,11 @@ pub(crate) const PANE_MIGRATIONS: Migration = Migration::new();impl Db {- pub(crate) fn get_center_group(&self, _workspace: WorkspaceId) -> SerializedPaneGroup {+ pub(crate) fn get_center_group(&self, _workspace: &WorkspaceId) -> SerializedPaneGroup {unimplemented!()}- pub fn get_pane_group(&self, _pane_group_id: PaneGroupId) -> SerializedPaneGroup {+ pub(crate) fn _get_pane_group(&self, _workspace: &WorkspaceId) -> SerializedPaneGroup {unimplemented!()// let axis = self.get_pane_group_axis(pane_group_id);// let mut children: Vec<(usize, PaneGroupChild)> = Vec::new();@@ -91,31 +92,22 @@ impl Db {_workspace: &WorkspaceId,_center_pane_group: &SerializedPaneGroup,_connection: &Connection,- ) {+ ) -> Result<()> {// Delete the center pane group for this workspace and any of its children// Generate new pane group IDs as we go through// insert them+ Ok(())}- pub fn _get_pane(&self, _pane_id: PaneId) -> SerializedPane {- unimplemented!();- }-- pub(crate) fn get_dock_pane(&self, workspace: WorkspaceId) -> Option<SerializedDockPane> {- iife!({- self.prepare("SELECT anchor_position, visible FROM dock_panes WHERE workspace_id = ?")?- .with_bindings(workspace)?- .maybe_row::<SerializedDockPane>()- })- .log_err()- .flatten()+ pub(crate) fn get_dock_pane(&self, _workspace: &WorkspaceId) -> Option<SerializedPane> {+ unimplemented!()}pub(crate) fn save_dock_pane(- workspace: &WorkspaceId,- dock_pane: &SerializedDockPane,- connection: &Connection,- ) {+ _workspace: &WorkspaceId,+ _dock_pane: &SerializedPane,+ _connection: &Connection,+ ) -> Result<()> {// iife!({// self.prepare(// "INSERT INTO dock_panes (workspace_id, anchor_position, visible) VALUES (?, ?, ?);",@@ -124,6 +116,7 @@ impl Db {// .insert()// })// .log_err();+ Ok(())}}diff --git a/crates/sqlez/src/bindable.rs b/crates/sqlez/src/bindable.rsindex a22363ae63d..1ce350a550b 100644--- a/crates/sqlez/src/bindable.rs+++ b/crates/sqlez/src/bindable.rs@@ -1,5 +1,5 @@use std::{- ffi::{CString, OsStr},+ ffi::OsStr,os::unix::prelude::OsStrExt,path::{Path, PathBuf},};diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex a6ef7c6c01f..d1dbc6982b2 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -15,7 +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::{Db, SerializedWorkspace, WorkspaceId};+use db::{model::SerializedWorkspace, Db};use dock::{DefaultItemFactory, Dock, ToggleDockButton};use drag_and_drop::DragAndDrop;use fs::{self, Fs};@@ -1073,7 +1073,7 @@ pub enum Event {pub struct Workspace {weak_self: WeakViewHandle<Self>,- _db_id: WorkspaceId,+ // _db_id: WorkspaceId,client: Arc<Client>,user_store: ModelHandle<client::UserStore>,remote_entity_subscription: Option<client::Subscription>,@@ -1120,7 +1120,7 @@ enum FollowerItem {impl Workspace {pub fn new(- serialized_workspace: SerializedWorkspace,+ _serialized_workspace: Option<SerializedWorkspace>,project: ModelHandle<Project>,dock_default_factory: DefaultItemFactory,cx: &mut ViewContext<Self>,@@ -1217,7 +1217,7 @@ impl Workspace {let mut this = Workspace {modal: None,weak_self: weak_handle,- _db_id: serialized_workspace.workspace_id,+ // _db_id: serialized_workspace.workspace_id,center: PaneGroup::new(center_pane.clone()),dock,// When removing an item, the last element remaining in this array