Skip to content

lsp: Set workspace folder names - #60938

Merged
SomeoneToIgnore merged 6 commits into
zed-industries:mainfrom
0bkevin:fix/lsp-workspace-folder-name-60518
Jul 18, 2026
Merged

lsp: Set workspace folder names#60938
SomeoneToIgnore merged 6 commits into
zed-industries:mainfrom
0bkevin:fix/lsp-workspace-folder-name-60518

Conversation

@0bkevin

@0bkevin 0bkevin commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

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:

Starting service instance ""

With a derived workspace folder name it logged:

Starting service instance "zed-60518-project"

Tested on macOS.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Fixed language servers receiving empty workspace folder names.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jul 14, 2026
@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Jul 14, 2026

@SomeoneToIgnore SomeoneToIgnore left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, looks quite nice.
Let's tidy up the code a bit and merge this.

Comment thread crates/lsp/src/lsp.rs Outdated
Comment thread crates/lsp/src/lsp.rs Outdated
Comment thread crates/lsp/src/lsp.rs Outdated
@SomeoneToIgnore SomeoneToIgnore self-assigned this Jul 14, 2026
@SomeoneToIgnore SomeoneToIgnore added the area:language server An umbrella label for all language servers label Jul 16, 2026
@0bkevin
0bkevin force-pushed the fix/lsp-workspace-folder-name-60518 branch from b3097a8 to 77bcaf0 Compare July 17, 2026 23:42
@0bkevin

0bkevin commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! @SomeoneToIgnore all comments resolved.

@SomeoneToIgnore SomeoneToIgnore left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

auto-merge was automatically disabled July 18, 2026 07:52

Head branch was pushed to by a user without write access

@0bkevin

0bkevin commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

This should fix the Windows test failure. The test now builds the workspace URI from a native absolute temporary path, so Windows receives a drive-qualified file URI and resolves the folder name to my project, matching Unix. The fix is in 2f3cea17f3.

@SomeoneToIgnore
SomeoneToIgnore added this pull request to the merge queue Jul 18, 2026
Merged via the queue into zed-industries:main with commit c9e8e61 Jul 18, 2026
34 checks passed
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
# Objective

Fixes zed-industries#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.
playdohface pushed a commit to playdohface/zed that referenced this pull request Aug 29, 2026
# Objective

Fixes zed-industries#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:language server An umbrella label for all language servers cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LSP initialize sends empty workspaceFolders[].name

2 participants