Detailed changes
@@ -161,7 +161,6 @@
/extensions/glsl/ @zed-industries/ecosystem-team
/extensions/html/ @zed-industries/ecosystem-team
/extensions/proto/ @zed-industries/ecosystem-team
-/extensions/slash-commands-example/ @zed-industries/ecosystem-team
/extensions/test-extension/ @zed-industries/ecosystem-team
/extensions/workflows/ @zed-industries/ecosystem-team
@@ -7,7 +7,6 @@ on:
- main
paths:
- extensions/**
- - '!extensions/slash-commands-example/**'
- '!extensions/test-extension/**'
- '!extensions/workflows/**'
- '!extensions/*.md'
@@ -28,16 +27,23 @@ jobs:
CHANGED_FILES="$(git diff --name-only "$COMPARE_REV" "$GITHUB_SHA")"
# Detect changed extension directories (excluding extensions/workflows)
CHANGED_EXTENSIONS=$(echo "$CHANGED_FILES" | grep -oP '^extensions/[^/]+(?=/)' | sort -u | grep -v '^extensions/workflows$' || true)
+ # Filter out deleted extensions
+ EXISTING_EXTENSIONS=""
+ for ext in $CHANGED_EXTENSIONS; do
+ if [ -f "$ext/extension.toml" ]; then
+ EXISTING_EXTENSIONS=$(printf '%s\n%s' "$EXISTING_EXTENSIONS" "$ext")
+ fi
+ done
+ CHANGED_EXTENSIONS=$(echo "$EXISTING_EXTENSIONS" | sed '/^$/d')
if [ -n "$CHANGED_EXTENSIONS" ]; then
EXTENSIONS_JSON=$(echo "$CHANGED_EXTENSIONS" | jq -R -s -c 'split("\n") | map(select(length > 0))')
else
EXTENSIONS_JSON="[]"
fi
- # Filter out newly added or entirely removed extensions
+ # Filter out newly added extensions
FILTERED="[]"
for ext in $(echo "$EXTENSIONS_JSON" | jq -r '.[]'); do
- if git show HEAD~1:"$ext/extension.toml" >/dev/null 2>&1 && \
- [ -f "$ext/extension.toml" ]; then
+ if git show HEAD~1:"$ext/extension.toml" >/dev/null 2>&1; then
FILTERED=$(echo "$FILTERED" | jq -c --arg e "$ext" '. + [$e]')
fi
done
@@ -106,6 +106,14 @@ jobs:
check_pattern "run_tests" '^(docs/|script/update_top_ranking_issues/|\.github/(ISSUE_TEMPLATE|workflows/(?!run_tests))|extensions/)' -qvP
# Detect changed extension directories (excluding extensions/workflows)
CHANGED_EXTENSIONS=$(echo "$CHANGED_FILES" | grep -oP '^extensions/[^/]+(?=/)' | sort -u | grep -v '^extensions/workflows$' || true)
+ # Filter out deleted extensions
+ EXISTING_EXTENSIONS=""
+ for ext in $CHANGED_EXTENSIONS; do
+ if [ -f "$ext/extension.toml" ]; then
+ EXISTING_EXTENSIONS=$(printf '%s\n%s' "$EXISTING_EXTENSIONS" "$ext")
+ fi
+ done
+ CHANGED_EXTENSIONS=$(echo "$EXISTING_EXTENSIONS" | sed '/^$/d')
if [ -n "$CHANGED_EXTENSIONS" ]; then
EXTENSIONS_JSON=$(echo "$CHANGED_EXTENSIONS" | jq -R -s -c 'split("\n") | map(select(length > 0))')
else
@@ -16019,13 +16019,6 @@ version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589"
-[[package]]
-name = "slash_commands_example"
-version = "0.1.0"
-dependencies = [
- "zed_extension_api 0.1.0",
-]
-
[[package]]
name = "slotmap"
version = "1.0.7"
@@ -234,7 +234,6 @@ members = [
"extensions/glsl",
"extensions/html",
"extensions/proto",
- "extensions/slash-commands-example",
"extensions/test-extension",
#
@@ -1,16 +0,0 @@
-[package]
-name = "slash_commands_example"
-version = "0.1.0"
-edition.workspace = true
-publish.workspace = true
-license = "Apache-2.0"
-
-[lints]
-workspace = true
-
-[lib]
-path = "src/slash_commands_example.rs"
-crate-type = ["cdylib"]
-
-[dependencies]
-zed_extension_api = "0.1.0"
@@ -1 +0,0 @@
-../../LICENSE-APACHE
@@ -1,84 +0,0 @@
-# Slash Commands Example Extension
-
-This is an example extension showcasing how to write slash commands.
-
-See: [Extensions: Slash Commands](https://zed.dev/docs/extensions/slash-commands) in the Zed Docs.
-
-## Pre-requisites
-
-[Install Rust Toolchain](https://www.rust-lang.org/tools/install):
-
-```sh
-curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-```
-
-## Setup
-
-```sh
-git clone https://github.com/zed-industries/zed.git
-cp -RL zed/extensions/slash-commands-example .
-
-cd slash-commands-example/
-
-# Update Cargo.toml to make it standalone
-cat > Cargo.toml << EOF
-[package]
-name = "slash_commands_example"
-version = "0.1.0"
-edition = "2021"
-license = "Apache-2.0"
-
-[lib]
-path = "src/slash_commands_example.rs"
-crate-type = ["cdylib"]
-
-[dependencies]
-zed_extension_api = "0.1.0"
-EOF
-
-curl -O https://raw.githubusercontent.com/rust-lang/rust/master/LICENSE-APACHE
-echo "# Zed Slash Commands Example Extension" > README.md
-echo "Cargo.lock" > .gitignore
-echo "target/" >> .gitignore
-echo "*.wasm" >> .gitignore
-
-git init
-git add .
-git commit -m "Initial commit"
-
-cd ..
-mv slash-commands-example MY-SUPER-COOL-ZED-EXTENSION
-zed $_
-```
-
-## Installation
-
-1. Open the command palette (`cmd-shift-p` or `ctrl-shift-p`).
-2. Launch `zed: install dev extension`
-3. Select the extension folder created above
-
-## Test
-
-Open the assistant and type `/echo` and `/pick-one` at the beginning of a line.
-
-## Customization
-
-Open the `extensions.toml` file and set the `id`, `name`, `description`, `authors` and `repository` fields.
-
-Rename `slash-commands-example.rs` you'll also have to update `Cargo.toml`
-
-## Rebuild
-
-Rebuild to see these changes reflected:
-
-1. Open Zed Extensions (`cmd-shift-x` or `ctrl-shift-x`).
-2. Click `Rebuild` next to your Dev Extension (formerly "Slash Command Example")
-
-## Troubleshooting / Logs
-
-- [zed.dev docs: Troubleshooting](https://zed.dev/docs/troubleshooting)
-
-## Documentation
-
-- [zed.dev docs: Extensions: Developing Extensions](https://zed.dev/docs/extensions/developing-extensions)
-- [zed.dev docs: Extensions: Slash Commands](https://zed.dev/docs/extensions/slash-commands)
@@ -1,15 +0,0 @@
-id = "slash-commands-example"
-name = "Slash Commands Example"
-description = "An example extension showcasing slash commands."
-version = "0.1.0"
-schema_version = 1
-authors = ["Zed Industries <hi@zed.dev>"]
-repository = "https://github.com/zed-industries/zed"
-
-[slash_commands.echo]
-description = "echoes the provided input"
-requires_argument = true
-
-[slash_commands.pick-one]
-description = "pick one of three options"
-requires_argument = true
@@ -1,90 +0,0 @@
-use zed_extension_api::{
- self as zed, SlashCommand, SlashCommandArgumentCompletion, SlashCommandOutput,
- SlashCommandOutputSection, Worktree,
-};
-
-struct SlashCommandsExampleExtension;
-
-impl zed::Extension for SlashCommandsExampleExtension {
- fn new() -> Self {
- SlashCommandsExampleExtension
- }
-
- fn complete_slash_command_argument(
- &self,
- command: SlashCommand,
- _args: Vec<String>,
- ) -> Result<Vec<zed_extension_api::SlashCommandArgumentCompletion>, String> {
- match command.name.as_str() {
- "echo" => Ok(vec![]),
- "pick-one" => Ok(vec![
- SlashCommandArgumentCompletion {
- label: "Option One".to_string(),
- new_text: "option-1".to_string(),
- run_command: true,
- },
- SlashCommandArgumentCompletion {
- label: "Option Two".to_string(),
- new_text: "option-2".to_string(),
- run_command: true,
- },
- SlashCommandArgumentCompletion {
- label: "Option Three".to_string(),
- new_text: "option-3".to_string(),
- run_command: true,
- },
- ]),
- command => Err(format!("unknown slash command: \"{command}\"")),
- }
- }
-
- fn run_slash_command(
- &self,
- command: SlashCommand,
- args: Vec<String>,
- _worktree: Option<&Worktree>,
- ) -> Result<SlashCommandOutput, String> {
- match command.name.as_str() {
- "echo" => {
- if args.is_empty() {
- return Err("nothing to echo".to_string());
- }
-
- let text = args.join(" ");
-
- Ok(SlashCommandOutput {
- sections: vec![SlashCommandOutputSection {
- range: (0..text.len()).into(),
- label: "Echo".to_string(),
- }],
- text,
- })
- }
- "pick-one" => {
- let Some(selection) = args.first() else {
- return Err("no option selected".to_string());
- };
-
- match selection.as_str() {
- "option-1" | "option-2" | "option-3" => {}
- invalid_option => {
- return Err(format!("{invalid_option} is not a valid option"));
- }
- }
-
- let text = format!("You chose {selection}.");
-
- Ok(SlashCommandOutput {
- sections: vec![SlashCommandOutputSection {
- range: (0..text.len()).into(),
- label: format!("Pick One: {selection}"),
- }],
- text,
- })
- }
- command => Err(format!("unknown slash command: \"{command}\"")),
- }
- }
-}
-
-zed::register_extension!(SlashCommandsExampleExtension);
@@ -25,7 +25,6 @@ pub(crate) fn extension_auto_bump() -> Workflow {
Push::default()
.add_branch("main")
.add_path("extensions/**")
- .add_path("!extensions/slash-commands-example/**")
.add_path("!extensions/test-extension/**")
.add_path("!extensions/workflows/**")
.add_path("!extensions/*.md"),
@@ -42,12 +41,11 @@ fn detect_changed_extensions() -> NamedJob {
CHANGED_FILES="$(git diff --name-only "$COMPARE_REV" "$GITHUB_SHA")"
"#};
- let filter_new_and_removed = indoc! {r#"
- # Filter out newly added or entirely removed extensions
+ let filter_newly_added = indoc! {r#"
+ # Filter out newly added extensions
FILTERED="[]"
for ext in $(echo "$EXTENSIONS_JSON" | jq -r '.[]'); do
- if git show HEAD~1:"$ext/extension.toml" >/dev/null 2>&1 && \
- [ -f "$ext/extension.toml" ]; then
+ if git show HEAD~1:"$ext/extension.toml" >/dev/null 2>&1; then
FILTERED=$(echo "$FILTERED" | jq -c --arg e "$ext" '. + [$e]')
fi
done
@@ -58,7 +56,7 @@ fn detect_changed_extensions() -> NamedJob {
"{preamble}{detect}{filter}",
preamble = preamble,
detect = DETECT_CHANGED_EXTENSIONS_SCRIPT,
- filter = filter_new_and_removed,
+ filter = filter_newly_added,
);
let step = named::bash(script).id("detect");
@@ -337,6 +337,14 @@ pub fn tests_pass(jobs: &[NamedJob], extra_job_names: &[&str]) -> NamedJob {
pub(crate) const DETECT_CHANGED_EXTENSIONS_SCRIPT: &str = indoc::indoc! {r#"
# Detect changed extension directories (excluding extensions/workflows)
CHANGED_EXTENSIONS=$(echo "$CHANGED_FILES" | grep -oP '^extensions/[^/]+(?=/)' | sort -u | grep -v '^extensions/workflows$' || true)
+ # Filter out deleted extensions
+ EXISTING_EXTENSIONS=""
+ for ext in $CHANGED_EXTENSIONS; do
+ if [ -f "$ext/extension.toml" ]; then
+ EXISTING_EXTENSIONS=$(printf '%s\n%s' "$EXISTING_EXTENSIONS" "$ext")
+ fi
+ done
+ CHANGED_EXTENSIONS=$(echo "$EXISTING_EXTENSIONS" | sed '/^$/d')
if [ -n "$CHANGED_EXTENSIONS" ]; then
EXTENSIONS_JSON=$(echo "$CHANGED_EXTENSIONS" | jq -R -s -c 'split("\n") | map(select(length > 0))')
else