Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
feedback: Add action for listing installed extensions (#48664)
Matthew Chisolmf9662f484d32
diff --git a/Cargo.lock b/Cargo.lockindex ccf29c1b293..32024536dbc 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -6183,6 +6183,7 @@ dependencies = [name = "feedback"version = "0.1.0"dependencies = [+ "extension_host","gpui","system_specs","urlencoding",diff --git a/crates/feedback/Cargo.toml b/crates/feedback/Cargo.tomlindex c2279d77886..6a595bf4ee4 100644--- a/crates/feedback/Cargo.toml+++ b/crates/feedback/Cargo.toml@@ -15,6 +15,7 @@ path = "src/feedback.rs"test-support = [][dependencies]+extension_host.workspace = truegpui.workspace = truesystem_specs.workspace = trueurlencoding.workspace = truediff --git a/crates/feedback/src/feedback.rs b/crates/feedback/src/feedback.rsindex 57bddb6ae7e..4a9f92d6d26 100644--- a/crates/feedback/src/feedback.rs+++ b/crates/feedback/src/feedback.rs@@ -1,3 +1,4 @@+use extension_host::ExtensionStore;use gpui::{App, ClipboardItem, PromptLevel, actions};use system_specs::{CopySystemSpecsIntoClipboard, SystemSpecs};use util::ResultExt;@@ -9,6 +10,8 @@ actions!([/// Opens the Zed repository on GitHub.OpenZedRepo,+ /// Copies installed extensions to the clipboard for bug reports.+ CopyInstalledExtensionsIntoClipboard]);@@ -65,6 +68,17 @@ pub fn init(cx: &mut App) {}).detach();})+ .register_action(|_, _: &CopyInstalledExtensionsIntoClipboard, window, cx| {+ let clipboard_text = format_installed_extensions_for_clipboard(cx);+ cx.write_to_clipboard(ClipboardItem::new_string(clipboard_text.clone()));+ drop(window.prompt(+ PromptLevel::Info,+ "Copied into clipboard",+ Some(&clipboard_text),+ &["OK"],+ cx,+ ));+ }).register_action(|_, _: &RequestFeature, _, cx| {cx.open_url(REQUEST_FEATURE_URL);})@@ -96,3 +110,32 @@ pub fn init(cx: &mut App) {}).detach();}++fn format_installed_extensions_for_clipboard(cx: &mut App) -> String {+ let store = ExtensionStore::global(cx);+ let store = store.read(cx);+ let mut lines = Vec::with_capacity(store.extension_index.extensions.len());++ for (extension_id, entry) in store.extension_index.extensions.iter() {+ let line = format!(+ "- {} ({}) v{}{}",+ entry.manifest.name,+ extension_id,+ entry.manifest.version,+ if entry.dev { " (dev)" } else { "" }+ );+ lines.push(line);+ }++ lines.sort();++ if lines.is_empty() {+ return "No extensions installed.".to_string();+ }++ format!(+ "Installed extensions ({}):\n{}",+ lines.len(),+ lines.join("\n")+ )+}diff --git a/docs/src/troubleshooting.md b/docs/src/troubleshooting.mdindex 0ec95cd55e0..9ef5cc9f321 100644--- a/docs/src/troubleshooting.md+++ b/docs/src/troubleshooting.md@@ -17,6 +17,7 @@ When reporting issues or seeking help, it's useful to know your Zed version and- {#action zed::About}: Find your Zed version number- {#action zed::CopySystemSpecsIntoClipboard}: Populate your clipboard with Zed version number, operating system version, and hardware specs+- {#action zed::CopyInstalledExtensionsIntoClipboard}: Populate your clipboard with a list of your installed extensions and versions## Zed Log