Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
WIP: Remove focus side effects from toggle dock commands
Mikayla Maki1a23fe91b47e
diff --git a/assets/keymaps/default.json b/assets/keymaps/default.jsonindex 35182dfaa66..7e1a8429bfd 100644--- a/assets/keymaps/default.json+++ b/assets/keymaps/default.json@@ -373,30 +373,9 @@"workspace::ActivatePane",8],- "cmd-b": [- "workspace::ToggleLeftDock",- { "focus": true }- ],- "cmd-shift-b": [- "workspace::ToggleLeftDock",- { "focus": false }- ],- "cmd-r": [- "workspace::ToggleRightDock",- { "focus": true }- ],- "cmd-shift-r": [- "workspace::ToggleRightDock",- { "focus": false }- ],- "cmd-j": [- "workspace::ToggleBottomDock",- { "focus": true }- ],- "cmd-shift-j": [- "workspace::ToggleBottomDock",- { "focus": false }- ],+ "cmd-b": "workspace::ToggleLeftDock",+ "cmd-r": "workspace::ToggleRightDock",+ "cmd-j": "workspace::ToggleBottomDock","cmd-shift-f": "workspace::NewSearch","cmd-k cmd-t": "theme_selector::Toggle","cmd-k cmd-s": "zed::OpenKeymap",diff --git a/crates/welcome/src/welcome.rs b/crates/welcome/src/welcome.rsindex cef6f53a6ec..b7460c4c461 100644--- a/crates/welcome/src/welcome.rs+++ b/crates/welcome/src/welcome.rs@@ -32,7 +32,7 @@ pub fn init(cx: &mut AppContext) {pub fn show_welcome_experience(app_state: &Arc<AppState>, cx: &mut AppContext) {open_new(&app_state, cx, |workspace, cx| {- workspace.toggle_dock(DockPosition::Left, false, cx);+ workspace.toggle_dock(DockPosition::Left, cx);let welcome_page = cx.add_view(|cx| WelcomePage::new(workspace, cx));workspace.add_item_to_center(Box::new(welcome_page.clone()), cx);cx.focus(&welcome_page);diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex 6309b1d01f5..1a14f39fb9d 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -103,24 +103,6 @@ pub trait Modal: View {#[derive(Clone, PartialEq)]pub struct RemoveWorktreeFromProject(pub WorktreeId);-#[derive(Copy, Clone, Default, Deserialize, PartialEq)]-pub struct ToggleLeftDock {- #[serde(default = "default_true")]- pub focus: bool,-}--#[derive(Copy, Clone, Default, Deserialize, PartialEq)]-pub struct ToggleBottomDock {- #[serde(default = "default_true")]- pub focus: bool,-}--#[derive(Copy, Clone, Default, Deserialize, PartialEq)]-pub struct ToggleRightDock {- #[serde(default = "default_true")]- pub focus: bool,-}-actions!(workspace,[@@ -143,16 +125,14 @@ actions!(Restart,Welcome,ToggleZoom,+ ToggleLeftDock,+ ToggleRightDock,+ ToggleBottomDock,]);actions!(zed, [OpenSettings]);-impl_actions!(- workspace,- [ToggleLeftDock, ToggleBottomDock, ToggleRightDock]-);-#[derive(Clone, PartialEq)]pub struct OpenPaths {pub paths: Vec<PathBuf>,@@ -268,14 +248,14 @@ pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {cx.add_action(|workspace: &mut Workspace, _: &ActivateNextPane, cx| {workspace.activate_next_pane(cx)});- cx.add_action(|workspace: &mut Workspace, action: &ToggleLeftDock, cx| {- workspace.toggle_dock(DockPosition::Left, action.focus, cx);+ cx.add_action(|workspace: &mut Workspace, _: &ToggleLeftDock, cx| {+ workspace.toggle_dock(DockPosition::Left, cx);});- cx.add_action(|workspace: &mut Workspace, action: &ToggleRightDock, cx| {- workspace.toggle_dock(DockPosition::Right, action.focus, cx);+ cx.add_action(|workspace: &mut Workspace, _: &ToggleRightDock, cx| {+ workspace.toggle_dock(DockPosition::Right, cx);});- cx.add_action(|workspace: &mut Workspace, action: &ToggleBottomDock, cx| {- workspace.toggle_dock(DockPosition::Bottom, action.focus, cx);+ cx.add_action(|workspace: &mut Workspace, _: &ToggleBottomDock, cx| {+ workspace.toggle_dock(DockPosition::Bottom, cx);});cx.add_action(Workspace::activate_pane_at_index);cx.add_action(|workspace: &mut Workspace, _: &ReopenClosedItem, cx| {@@ -1596,7 +1576,6 @@ impl Workspace {pub fn toggle_dock(&mut self,dock_side: DockPosition,- focus: bool,cx: &mut ViewContext<Self>,) {let dock = match dock_side {@@ -1608,12 +1587,6 @@ impl Workspace {let open = !dock.is_open();dock.set_open(open, cx);});-- if dock.read(cx).is_open() && focus {- cx.focus(dock);- } else {- cx.focus_self();- }cx.notify();self.serialize_workspace(cx);}@@ -3599,10 +3572,6 @@ fn parse_pixel_position_env_var(value: &str) -> Option<Vector2F> {Some(vec2f(width as f32, height as f32))}-fn default_true() -> bool {- true-}-#[cfg(test)]mod tests {use super::*;@@ -4187,7 +4156,7 @@ mod tests {let fs = FakeFs::new(cx.background());let project = Project::test(fs, [], cx).await;- let (window_id, workspace) = cx.add_window(|cx| Workspace::test_new(project, cx));+ let (_, workspace) = cx.add_window(|cx| Workspace::test_new(project, cx));let panel = workspace.update(cx, |workspace, cx| {let panel = cx.add_view(|_| TestPanel::new(DockPosition::Right));diff --git a/crates/zed/src/menus.rs b/crates/zed/src/menus.rsindex adc1f81589f..ecfd567e78d 100644--- a/crates/zed/src/menus.rs+++ b/crates/zed/src/menus.rs@@ -91,15 +91,15 @@ pub fn menus() -> Vec<Menu<'static>> {MenuItem::separator(),MenuItem::action("Toggle Left Dock",- workspace::ToggleLeftDock { focus: false },+ workspace::ToggleLeftDock,),MenuItem::action("Toggle Right Dock",- workspace::ToggleRightDock { focus: false },+ workspace::ToggleRightDock,),MenuItem::action("Toggle Bottom Dock",- workspace::ToggleBottomDock { focus: false },+ workspace::ToggleBottomDock,),MenuItem::submenu(Menu {name: "Editor Layout",diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rsindex c22967686ac..6dbddae2ada 100644--- a/crates/zed/src/zed.rs+++ b/crates/zed/src/zed.rs@@ -354,7 +354,7 @@ pub fn initialize_workspace(.map_or(false, |entry| entry.is_dir())}){- workspace.toggle_dock(project_panel_position, false, cx);+ workspace.toggle_dock(project_panel_position, cx);}workspace.add_panel(terminal_panel, cx)