# snippets: Strip path separators from language snippet file names \(\#61421\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/c3422b97a9e765db70ada8dc30066a76e393fd1c)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: c3422b97a9e765db70ada8dc30066a76e393fd1c

Requested commit: c3422b97a9e765db70ada8dc30066a76e393fd1c

Commit: c3422b97a9e765db70ada8dc30066a76e393fd1c

Tree: e85c2a515e4584eb76c034de3eea931241ec68cc

Author: Ibrahim Khan

Committer: GitHub

## Message

```
snippets: Strip path separators from language snippet file names (#61421)

Closes #59620

## Problem

A language whose name contains a `/`, such as a custom `PL/X` extension
(`lsp_id` → `pl/x`), broke snippets end to end:

- The `snippets: configure snippets` action wrote the file to
`~/.config/zed/snippets/pl/x.json`, i.e. inside a `pl/` subdirectory.
- The snippet scanner reads `snippets/` non-recursively and skips
directories, so that file was never loaded and the snippet could never
be used.
- The completion lookup keyed off the raw `lsp_id` (`pl/x`), which
wouldn't have matched the file-stem key even if the file had been
scanned.

So Zed's own UI created a snippet file it could never read back.

## Fix

Add `LanguageName::snippet_scope_id()` (the `lsp_id` with `/` and `\`
removed) and use it everywhere a language maps to its snippet file name
or lookup key:

- the Configure Snippets writer and its "already configured" label, and
- the two completion lookups in `editor`.

`PL/X` now maps to a flat `plx.json`, as suggested in the issue. The
`editor::InsertSnippet` action is intentionally left unchanged: its
`language` field is documented to be the snippet file name stem, which
is already separator-free.

Note: files created under the old behavior (nested `foo/bar.json`)
aren't migrated; re-running Configure Snippets writes the corrected flat
file.

## Testing

- Added a `language_core` unit test asserting `snippet_scope_id()`
strips `/` and `\` (e.g. `PL/X` → `plx`).
- `cargo test -p language_core` passes.
- `./script/clippy -p language_core -p language` passes.
- Docs Prettier passes.

Release Notes:

- Fixed snippets being unusable for languages whose name contains a `/`
character
```

## Parents

- [6297c88f428a99741a7bfb33f31dfe98123bb8e4](https://git.cafe/gitcafe/zed/commit/6297c88f428a99741a7bfb33f31dfe98123bb8e4?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/c3422b97a9e765db70ada8dc30066a76e393fd1c?format=markdown)
