extension_host: Restore project LSP settings for extensions using old API versions (#63072) (cherry-pick to preview) (#63082)
Some checks are pending
run_tests / orchestrate (push) Waiting to run
run_tests / run_tests_windows (push) Blocked by required conditions
run_tests / check_workspace_binaries (push) Blocked by required conditions
run_tests / check_style (push) Waiting to run
run_tests / clippy_windows (push) Blocked by required conditions
run_tests / clippy_linux (push) Blocked by required conditions
run_tests / clippy_mac (push) Blocked by required conditions
run_tests / clippy_mac_x86_64 (push) Blocked by required conditions
run_tests / run_tests_linux (push) Blocked by required conditions
run_tests / run_tests_mac (push) Blocked by required conditions
run_tests / miri_scheduler (push) Blocked by required conditions
run_tests / doctests (push) Blocked by required conditions
run_tests / build_visual_tests_binary (push) Blocked by required conditions
run_tests / check_wasm (push) Blocked by required conditions
run_tests / check_licenses (push) Blocked by required conditions
run_tests / check_dependencies (push) Blocked by required conditions
run_tests / check_docs (push) Blocked by required conditions
run_tests / check_scripts (push) Blocked by required conditions
run_tests / check_postgres_and_protobuf_migrations (push) Blocked by required conditions
run_tests / extension_tests (push) Blocked by required conditions
run_tests / tests_pass (push) Blocked by required conditions

Cherry-pick of #63072 to preview

----
# Objective

Fixes #43932.

Extensions built with `zed_extension_api` 0.0.6 or 0.1 pass the absolute
worktree root in `SettingsLocation.path`. After #38744 changed core
settings locations to `RelPath`, `RelPath::new` returns an error for
that absolute value. The conversion produces `None`, so
`ProjectSettings::get` falls back to global settings. This regressed the
behavior fixed in #10859.

The current LaTeX and Typst extensions both use API 0.1, matching the
two extension surfaces reported in the issue.

# Solution

For the 0.0.6 and 0.1 WIT adapters, treat the legacy path as the
worktree root (`RelPath::empty()`) and preserve the worktree ID. API 0.2
and later already send an empty relative path, so their behavior is
unchanged.

The two version adapters each have a regression test for the legacy
absolute-root input.

# Testing

- `cargo test -p extension_host
settings_location_targets_the_worktree_root` (2 passed)
- `cargo test -p extension_host -- --skip
extension_store_test::test_extension_store_with_test_extension` (10
passed; the skipped fixture needs the `wasm32-wasip2` target, which is
not installed in the local Homebrew Rust toolchain)
- `cargo clippy -p extension_host --all-targets -- -D warnings`
- `cargo fmt --check`
- `cargo build -p zed`

End-to-end check with an isolated `--user-data-dir`, a trusted folder
worktree, LaTeX extension 0.2.3, and texlab 5.26.0:

- Zed 1.16.1 sent the global sentinel for both startup and a live
project-settings edit.
- This branch sent the project sentinel on startup.
- Changing the project sentinel from V2 to V3 produced a new
`workspace/didChangeConfiguration` with V3, and texlab's follow-up
`workspace/configuration` request also returned V3.



![zed-43932-before-after.png](https://github.com/user-attachments/assets/d7e21fa7-0b48-4195-a0fb-36e4f1aa84e3)

# 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
- [x] Tests cover the new behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed project-level language server settings being ignored by
extensions built with extension API versions before and including
v0.1.0.

---------

Co-authored-by: MrSubidubi <finn@zed.dev>

Co-authored-by: Zhuoyuan Hao (Larry Hao / 郝卓远) <107194248+hhh2210@users.noreply.github.com>
Co-authored-by: MrSubidubi <finn@zed.dev>
This commit is contained in:
zed-zippy[bot] 2026-08-22 12:33:50 +00:00 committed by GitHub
parent 0956f489e2
commit ddb0ef0af2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View file

@ -56,7 +56,13 @@ impl From<SettingsLocation> for latest::SettingsLocation {
fn from(value: SettingsLocation) -> Self {
Self {
worktree_id: value.worktree_id,
path: value.path,
// Passing the path here causes project settings reads to fail,
// since the extension passes the absolute path to the worktree,
// not a relative one like the settings API expects.
//
// This has been fixed in the API itself as of v0.2.0. Align the behavior
// here so that older extensions can also read project settings.
path: String::new(),
}
}
}

View file

@ -77,7 +77,13 @@ impl From<SettingsLocation> for latest::SettingsLocation {
fn from(value: SettingsLocation) -> Self {
Self {
worktree_id: value.worktree_id,
path: value.path,
// Passing the path here causes project settings reads to fail,
// since the extension passes the absolute path to the worktree,
// not a relative one like the settings API expects.
//
// This has been fixed in the API itself as of v0.2.0. Align the behavior
// here so that older extensions can also read project settings.
path: String::new(),
}
}
}