Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add zoom serialization to the workspace
Mikayla Maki6662066821b6
diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rsindex d27818d2028..dd2aa5a8189 100644--- a/crates/workspace/src/persistence.rs+++ b/crates/workspace/src/persistence.rs@@ -162,6 +162,12 @@ define_connection! {ALTER TABLE workspaces ADD COLUMN right_dock_active_panel TEXT;ALTER TABLE workspaces ADD COLUMN bottom_dock_visible INTEGER; //boolALTER TABLE workspaces ADD COLUMN bottom_dock_active_panel TEXT;+ ),+ // Add panel zoom persistence+ sql!(+ ALTER TABLE workspaces ADD COLUMN left_dock_zoom INTEGER; //bool+ ALTER TABLE workspaces ADD COLUMN right_dock_zoom INTEGER; //bool+ ALTER TABLE workspaces ADD COLUMN bottom_dock_zoom INTEGER; //bool)];}@@ -196,10 +202,13 @@ impl WorkspaceDb {display,left_dock_visible,left_dock_active_panel,+ left_dock_zoom,right_dock_visible,right_dock_active_panel,+ right_dock_zoom,bottom_dock_visible,- bottom_dock_active_panel+ bottom_dock_active_panel,+ bottom_dock_zoomFROM workspacesWHERE workspace_location = ?})@@ -244,22 +253,28 @@ impl WorkspaceDb {workspace_location,left_dock_visible,left_dock_active_panel,+ left_dock_zoom,right_dock_visible,right_dock_active_panel,+ right_dock_zoom,bottom_dock_visible,bottom_dock_active_panel,+ bottom_dock_zoom,timestamp)- VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, CURRENT_TIMESTAMP)+ VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, CURRENT_TIMESTAMP)ON CONFLICT DOUPDATE SETworkspace_location = ?2,left_dock_visible = ?3,left_dock_active_panel = ?4,- right_dock_visible = ?5,- right_dock_active_panel = ?6,- bottom_dock_visible = ?7,- bottom_dock_active_panel = ?8,+ left_dock_zoom = ?5,+ right_dock_visible = ?6,+ right_dock_active_panel = ?7,+ right_dock_zoom = ?8,+ bottom_dock_visible = ?9,+ bottom_dock_active_panel = ?10,+ bottom_dock_zoom = ?11,timestamp = CURRENT_TIMESTAMP))?((workspace.id, &workspace.location, workspace.docks)).context("Updating workspace")?;diff --git a/crates/workspace/src/persistence/model.rs b/crates/workspace/src/persistence/model.rsindex 9e3c4012cdc..9a374907fb7 100644--- a/crates/workspace/src/persistence/model.rs+++ b/crates/workspace/src/persistence/model.rs@@ -100,16 +100,19 @@ impl Bind for DockStructure {pub struct DockData {pub(crate) visible: bool,pub(crate) active_panel: Option<String>,+ pub(crate) zoom: bool}impl Column for DockData {fn column(statement: &mut Statement, start_index: i32) -> Result<(Self, i32)> {let (visible, next_index) = Option::<bool>::column(statement, start_index)?;let (active_panel, next_index) = Option::<String>::column(statement, next_index)?;+ let (zoom, next_index) = Option::<bool>::column(statement, next_index)?;Ok((DockData {visible: visible.unwrap_or(false),active_panel,+ zoom: zoom.unwrap_or(false)},next_index,))@@ -119,7 +122,8 @@ impl Column for DockData {impl Bind for DockData {fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {let next_index = statement.bind(&self.visible, start_index)?;- statement.bind(&self.active_panel, next_index)+ let next_index = statement.bind(&self.active_panel, next_index)?;+ statement.bind(&self.zoom, next_index)}}diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex 883b90d8090..da10f6ecee7 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -2836,7 +2836,7 @@ impl Workspace {cx.notify();}- fn serialize_workspace(&self, cx: &AppContext) {+ fn serialize_workspace(&self, cx: &ViewContext<Self>) {fn serialize_pane_handle(pane_handle: &ViewHandle<Pane>,cx: &AppContext,@@ -2879,7 +2879,7 @@ impl Workspace {}}- fn build_serialized_docks(this: &Workspace, cx: &AppContext) -> DockStructure {+ fn build_serialized_docks(this: &Workspace, cx: &ViewContext<Workspace>) -> DockStructure {let left_dock = this.left_dock.read(cx);let left_visible = left_dock.is_open();let left_active_panel = left_dock.visible_panel().and_then(|panel| {@@ -2888,6 +2888,10 @@ impl Workspace {.to_string(),)});+ let left_dock_zoom = left_dock+ .visible_panel()+ .map(|panel| panel.is_zoomed(cx))+ .unwrap_or(false);let right_dock = this.right_dock.read(cx);let right_visible = right_dock.is_open();@@ -2897,6 +2901,11 @@ impl Workspace {.to_string(),)});+ let right_dock_zoom = right_dock+ .visible_panel()+ .map(|panel| panel.is_zoomed(cx))+ .unwrap_or(false);+let bottom_dock = this.bottom_dock.read(cx);let bottom_visible = bottom_dock.is_open();@@ -2906,19 +2915,27 @@ impl Workspace {.to_string(),)});+ let bottom_dock_zoom = bottom_dock+ .visible_panel()+ .map(|panel| panel.is_zoomed(cx))+ .unwrap_or(false);+DockStructure {left: DockData {visible: left_visible,active_panel: left_active_panel,+ zoom: left_dock_zoom},right: DockData {visible: right_visible,active_panel: right_active_panel,+ zoom: right_dock_zoom},bottom: DockData {visible: bottom_visible,active_panel: bottom_active_panel,+ zoom: bottom_dock_zoom},}}@@ -3029,6 +3046,10 @@ impl Workspace {if let Some(active_panel) = docks.left.active_panel {if let Some(ix) = dock.panel_index_for_ui_name(&active_panel, cx) {dock.activate_panel(ix, cx);+ dock.active_panel()+ .map(|panel| {+ panel.set_zoomed(docks.left.zoom, cx)+ });}}});@@ -3037,6 +3058,11 @@ impl Workspace {if let Some(active_panel) = docks.right.active_panel {if let Some(ix) = dock.panel_index_for_ui_name(&active_panel, cx) {dock.activate_panel(ix, cx);+ dock.active_panel()+ .map(|panel| {+ panel.set_zoomed(docks.right.zoom, cx)+ });+}}});@@ -3045,6 +3071,11 @@ impl Workspace {if let Some(active_panel) = docks.bottom.active_panel {if let Some(ix) = dock.panel_index_for_ui_name(&active_panel, cx) {dock.activate_panel(ix, cx);+ dock.active_panel()+ .map(|panel| {+ panel.set_zoomed(docks.bottom.zoom, cx)+ });+}}});