From 2ea2ba358f215499f41e85cb3dd96c7016578425 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 13 Apr 2022 11:08:21 -0700 Subject: [PATCH] Add back toggle sidebar key bindings --- assets/keymaps/default.json | 16 +++++++++++++++- crates/workspace/src/sidebar.rs | 15 +++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index d0275a31b6..d9d5742b66 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -53,7 +53,21 @@ "cmd-t": "project_symbols::Toggle", "cmd-p": "file_finder::Toggle", "alt-shift-D": "diagnostics::Deploy", - "ctrl-alt-cmd-j": "journal::NewJournalEntry" + "ctrl-alt-cmd-j": "journal::NewJournalEntry", + "cmd-1": [ + "workspace::ToggleSidebarItemFocus", + { + "side": "Left", + "item_index": 0 + } + ], + "cmd-shift-!": [ + "workspace::ToggleSidebarItem", + { + "side": "Left", + "item_index": 0 + } + ] }, "ProjectSearchBar": { "enter": "project_search::Search", diff --git a/crates/workspace/src/sidebar.rs b/crates/workspace/src/sidebar.rs index 78b1d4a6ea..cd5ec32201 100644 --- a/crates/workspace/src/sidebar.rs +++ b/crates/workspace/src/sidebar.rs @@ -1,7 +1,6 @@ use super::Workspace; -use gpui::{ - elements::*, impl_internal_actions, platform::CursorStyle, AnyViewHandle, RenderContext, -}; +use gpui::{elements::*, impl_actions, platform::CursorStyle, AnyViewHandle, RenderContext}; +use serde::Deserialize; use std::{cell::RefCell, rc::Rc}; use theme::Theme; @@ -12,7 +11,7 @@ pub struct Sidebar { width: Rc>, } -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Deserialize)] pub enum Side { Left, Right, @@ -23,15 +22,15 @@ struct Item { view: AnyViewHandle, } -#[derive(Clone)] +#[derive(Clone, Deserialize)] pub struct ToggleSidebarItem(pub SidebarItemId); -#[derive(Clone)] +#[derive(Clone, Deserialize)] pub struct ToggleSidebarItemFocus(pub SidebarItemId); -impl_internal_actions!(workspace, [ToggleSidebarItem, ToggleSidebarItemFocus]); +impl_actions!(workspace, [ToggleSidebarItem, ToggleSidebarItemFocus]); -#[derive(Clone)] +#[derive(Clone, Deserialize)] pub struct SidebarItemId { pub side: Side, pub item_index: usize,