diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index a53f20aeda..06e19bbf88 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -95,7 +95,7 @@ actions!( ToggleLeftSidebar, ToggleRightSidebar, NewTerminal, - NewSearch, + NewSearch ] ); diff --git a/crates/zed/src/menus.rs b/crates/zed/src/menus.rs index 18e7d6fe9b..3865389e99 100644 --- a/crates/zed/src/menus.rs +++ b/crates/zed/src/menus.rs @@ -339,10 +339,8 @@ pub fn menus() -> Vec> { }, MenuItem::Separator, MenuItem::Action { - name: "Documentation", - action: Box::new(crate::OpenBrowser { - url: "https://zed.dev/docs".into(), - }), + name: "Copy System Specs Into Clipboard", + action: Box::new(crate::CopySystemSpecsIntoClipboard), }, MenuItem::Action { name: "Give Feedback", @@ -350,6 +348,13 @@ pub fn menus() -> Vec> { url: super::feedback::NEW_ISSUE_URL.into(), }), }, + MenuItem::Separator, + MenuItem::Action { + name: "Documentation", + action: Box::new(crate::OpenBrowser { + url: "https://zed.dev/docs".into(), + }), + }, MenuItem::Action { name: "Zed Twitter", action: Box::new(crate::OpenBrowser { diff --git a/crates/zed/src/system_specs.rs b/crates/zed/src/system_specs.rs new file mode 100644 index 0000000000..56eeeb8167 --- /dev/null +++ b/crates/zed/src/system_specs.rs @@ -0,0 +1,46 @@ +use std::{env, fmt::Display}; + +use gpui::AppContext; +use util::channel::ReleaseChannel; + +pub struct SystemSpecs { + os_name: &'static str, + os_version: Option, + app_version: &'static str, + release_channel: &'static str, + architecture: &'static str, +} + +impl SystemSpecs { + pub fn new(cx: &AppContext) -> Self { + let platform = cx.platform(); + + SystemSpecs { + os_name: platform.os_name(), + os_version: platform + .os_version() + .ok() + .map(|os_version| os_version.to_string()), + app_version: env!("CARGO_PKG_VERSION"), + release_channel: cx.global::().dev_name(), + architecture: env::consts::ARCH, + } + } +} + +impl Display for SystemSpecs { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let os_information = match &self.os_version { + Some(os_version) => format!("OS: {} {}", self.os_name, os_version), + None => format!("OS: {}", self.os_name), + }; + let system_specs = [ + os_information, + format!("Zed: {} ({})", self.app_version, self.release_channel), + format!("Architecture: {}", self.architecture), + ] + .join("\n"); + + write!(f, "{system_specs}") + } +} diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 099fb4eea9..0936e317f4 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -1,6 +1,7 @@ mod feedback; pub mod languages; pub mod menus; +pub mod system_specs; #[cfg(any(test, feature = "test-support"))] pub mod test; @@ -21,7 +22,7 @@ use gpui::{ }, impl_actions, platform::{WindowBounds, WindowOptions}, - AssetSource, AsyncAppContext, TitlebarOptions, ViewContext, WindowKind, + AssetSource, AsyncAppContext, ClipboardItem, TitlebarOptions, ViewContext, WindowKind, }; use language::Rope; use lazy_static::lazy_static; @@ -33,6 +34,7 @@ use serde::Deserialize; use serde_json::to_string_pretty; use settings::{keymap_file_json_schema, settings_file_json_schema, Settings}; use std::{env, path::Path, str, sync::Arc}; +use system_specs::SystemSpecs; use util::{channel::ReleaseChannel, paths, ResultExt}; pub use workspace; use workspace::{sidebar::SidebarSide, AppState, Workspace}; @@ -67,6 +69,7 @@ actions!( ResetBufferFontSize, InstallCommandLineInterface, ResetDatabase, + CopySystemSpecsIntoClipboard ] ); @@ -245,6 +248,19 @@ pub fn init(app_state: &Arc, cx: &mut gpui::MutableAppContext) { }, ); + cx.add_action( + |_: &mut Workspace, _: &CopySystemSpecsIntoClipboard, cx: &mut ViewContext| { + let system_specs = SystemSpecs::new(cx).to_string(); + let item = ClipboardItem::new(system_specs.clone()); + cx.prompt( + gpui::PromptLevel::Info, + &format!("Copied into clipboard:\n\n{system_specs}"), + &["OK"], + ); + cx.write_to_clipboard(item); + }, + ); + activity_indicator::init(cx); call::init(app_state.client.clone(), app_state.user_store.clone(), cx); settings::KeymapFileContent::load_defaults(cx);