Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add placeholder for extension slash commands (#12387)
Marshall Bowers01e86881f0dc
diff --git a/Cargo.lock b/Cargo.lockindex 307ce3aaf86..436a8795d09 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -3774,6 +3774,7 @@ dependencies = ["task","theme","toml 0.8.10",+ "ui","url","util","wasm-encoder",diff --git a/crates/extension/Cargo.toml b/crates/extension/Cargo.tomlindex 231318cd696..08b5250c3f9 100644--- a/crates/extension/Cargo.toml+++ b/crates/extension/Cargo.toml@@ -39,6 +39,7 @@ serde_json.workspace = truesettings.workspace = truetheme.workspace = truetoml.workspace = true+ui.workspace = trueurl.workspace = trueutil.workspace = truewasm-encoder.workspace = truediff --git a/crates/extension/src/extension_slash_command.rs b/crates/extension/src/extension_slash_command.rsindex 72ca429ce77..e5de0fe852d 100644--- a/crates/extension/src/extension_slash_command.rs+++ b/crates/extension/src/extension_slash_command.rs@@ -1,13 +1,16 @@-use crate::wasm_host::{WasmExtension, WasmHost};+use std::sync::{atomic::AtomicBool, Arc};+use anyhow::{anyhow, Result};use assistant_slash_command::{SlashCommand, SlashCommandOutput, SlashCommandOutputSection};use futures::FutureExt;use gpui::{AppContext, IntoElement, Task, WeakView, WindowContext};use language::LspAdapterDelegate;-use std::sync::{atomic::AtomicBool, Arc};+use ui::{prelude::*, ButtonLike, ElevationIndex};use wasmtime_wasi::WasiView;use workspace::Workspace;+use crate::wasm_host::{WasmExtension, WasmHost};+pub struct ExtensionSlashCommand {pub(crate) extension: WasmExtension,#[allow(unused)]@@ -48,6 +51,7 @@ impl SlashCommand for ExtensionSlashCommand {delegate: Arc<dyn LspAdapterDelegate>,cx: &mut WindowContext,) -> Task<Result<SlashCommandOutput>> {+ let command_name = SharedString::from(self.command.name.clone());let argument = argument.map(|arg| arg.to_string());let text = cx.background_executor().spawn(async move {let output = self@@ -82,8 +86,17 @@ impl SlashCommand for ExtensionSlashCommand {text,sections: vec![SlashCommandOutputSection {range,- render_placeholder: Arc::new(|_, _, _| {- "TODO: Extension command output".into_any_element()+ render_placeholder: Arc::new({+ let command_name = command_name.clone();+ move |id, unfold, _cx| {+ ButtonLike::new(id)+ .style(ButtonStyle::Filled)+ .layer(ElevationIndex::ElevatedSurface)+ .child(Icon::new(IconName::Code))+ .child(Label::new(command_name.clone()))+ .on_click(move |_event, cx| unfold(cx))+ .into_any_element()+ }}),}],})