Move zed actions to zed-actions

This commit is contained in:
Piotr Osiewicz 2023-06-12 13:00:08 +02:00 committed by Mikayla Maki
parent 4b87ce8952
commit 092cf93dae
No known key found for this signature in database
7 changed files with 35 additions and 44 deletions

2
Cargo.lock generated
View file

@ -1328,6 +1328,7 @@ dependencies = [
"theme_selector", "theme_selector",
"util", "util",
"workspace", "workspace",
"zed-actions",
] ]
[[package]] [[package]]
@ -8907,6 +8908,7 @@ dependencies = [
"vim", "vim",
"welcome", "welcome",
"workspace", "workspace",
"zed-actions",
] ]
[[package]] [[package]]

View file

@ -40,6 +40,7 @@ theme = { path = "../theme" }
theme_selector = { path = "../theme_selector" } theme_selector = { path = "../theme_selector" }
util = { path = "../util" } util = { path = "../util" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }
zed-actions = {path = "../zed-actions"}
anyhow.workspace = true anyhow.workspace = true
futures.workspace = true futures.workspace = true

View file

@ -301,7 +301,7 @@ impl CollabTitlebarItem {
self.user_menu.update(cx, |user_menu, cx| { self.user_menu.update(cx, |user_menu, cx| {
let items = if let Some(_) = self.user_store.read(cx).current_user() { let items = if let Some(_) = self.user_store.read(cx).current_user() {
vec![ vec![
ContextMenuItem::action("Settings", SignIn), ContextMenuItem::action("Settings", zed_actions::OpenSettings),
ContextMenuItem::action("Theme", theme_selector::Toggle), ContextMenuItem::action("Theme", theme_selector::Toggle),
ContextMenuItem::separator(), ContextMenuItem::separator(),
ContextMenuItem::action( ContextMenuItem::action(
@ -312,7 +312,7 @@ impl CollabTitlebarItem {
] ]
} else { } else {
vec![ vec![
ContextMenuItem::action("Settings", SignIn), ContextMenuItem::action("Settings", zed_actions::OpenSettings),
ContextMenuItem::action("Theme", theme_selector::Toggle), ContextMenuItem::action("Theme", theme_selector::Toggle),
ContextMenuItem::separator(), ContextMenuItem::separator(),
ContextMenuItem::action( ContextMenuItem::action(

View file

@ -1,14 +1,28 @@
pub fn add(left: usize, right: usize) -> usize { use gpui::actions;
left + right
}
#[cfg(test)] actions!(
mod tests { zed,
use super::*; [
About,
#[test] Hide,
fn it_works() { HideOthers,
let result = add(2, 2); ShowAll,
assert_eq!(result, 4); Minimize,
} Zoom,
} ToggleFullScreen,
Quit,
DebugElements,
OpenLog,
OpenLicenses,
OpenTelemetryLog,
OpenKeymap,
OpenSettings,
OpenLocalSettings,
OpenDefaultSettings,
OpenDefaultKeymap,
IncreaseBufferFontSize,
DecreaseBufferFontSize,
ResetBufferFontSize,
ResetDatabase,
]
);

View file

@ -67,7 +67,7 @@ util = { path = "../util" }
vim = { path = "../vim" } vim = { path = "../vim" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }
welcome = { path = "../welcome" } welcome = { path = "../welcome" }
zed-actions = {path = "../zed-actions"}
anyhow.workspace = true anyhow.workspace = true
async-compression = { version = "0.3", features = ["gzip", "futures-bufread"] } async-compression = { version = "0.3", features = ["gzip", "futures-bufread"] }
async-tar = "0.4.2" async-tar = "0.4.2"

View file

@ -871,6 +871,6 @@ pub fn background_actions() -> &'static [(&'static str, &'static dyn Action)] {
("Go to file", &file_finder::Toggle), ("Go to file", &file_finder::Toggle),
("Open command palette", &command_palette::Toggle), ("Open command palette", &command_palette::Toggle),
("Open recent projects", &recent_projects::OpenRecent), ("Open recent projects", &recent_projects::OpenRecent),
("Change your settings", &zed::OpenSettings), ("Change your settings", &zed_actions::OpenSettings),
] ]
} }

View file

@ -50,6 +50,7 @@ use workspace::{
notifications::simple_message_notification::MessageNotification, open_new, AppState, NewFile, notifications::simple_message_notification::MessageNotification, open_new, AppState, NewFile,
NewWindow, Workspace, WorkspaceSettings, NewWindow, Workspace, WorkspaceSettings,
}; };
use zed_actions::*;
#[derive(Deserialize, Clone, PartialEq)] #[derive(Deserialize, Clone, PartialEq)]
pub struct OpenBrowser { pub struct OpenBrowser {
@ -58,33 +59,6 @@ pub struct OpenBrowser {
impl_actions!(zed, [OpenBrowser]); impl_actions!(zed, [OpenBrowser]);
actions!(
zed,
[
About,
Hide,
HideOthers,
ShowAll,
Minimize,
Zoom,
ToggleFullScreen,
Quit,
DebugElements,
OpenLog,
OpenLicenses,
OpenTelemetryLog,
OpenKeymap,
OpenSettings,
OpenLocalSettings,
OpenDefaultSettings,
OpenDefaultKeymap,
IncreaseBufferFontSize,
DecreaseBufferFontSize,
ResetBufferFontSize,
ResetDatabase,
]
);
pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::AppContext) { pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::AppContext) {
cx.add_action(about); cx.add_action(about);
cx.add_global_action(|_: &Hide, cx: &mut gpui::AppContext| { cx.add_global_action(|_: &Hide, cx: &mut gpui::AppContext| {