# lsp: Set workspace folder names \(\#60938\) · gitcafe/zed

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

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

Visibility: public

Requested revision: c9e8e611dbc279afa0914d28c4d37ad07f38c03b

Requested commit: c9e8e611dbc279afa0914d28c4d37ad07f38c03b

Commit: c9e8e611dbc279afa0914d28c4d37ad07f38c03b

Tree: c318db813995d64a02eb91412497b48f68b2f7de

Author: Kevin Bravo

Committer: GitHub

## Message

````
lsp: Set workspace folder names (#60938)

# Objective

Fixes #60518.

Zed sends an empty `name` for entries in
`initialize.params.workspaceFolders`. Language servers such as
basedpyright use this field to identify workspace service instances,
resulting in an unnamed instance.

## Solution

Derive each workspace folder name from its URI, preferring the decoded
filesystem basename. For basename-less URIs, fall back to a non-empty
path, URI path segment, or the full URI.

Use the same construction for initialization parameters, dynamic
workspace-folder notifications, and `workspace/workspaceFolders`
responses so all LSP messages remain consistent.

## Testing

- `cargo fmt --all -- --check`
- `cargo test -p lsp`
- `cargo check -p project --all-targets --all-features`
- `./script/clippy -p lsp`
- `./script/clippy -p project`

Reproduced with basedpyright 1.39.9 over an LSP stdio session. Before
this change it logged:

```text
Starting service instance ""
```

With a derived workspace folder name it logged:

```text
Starting service instance "zed-60518-project"
```

Tested on macOS.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed language servers receiving empty workspace folder names.
````

## Parents

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

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