From 7eec89207ccfbef7ba366da22fc885079a5c0296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zhuoyuan=20Hao=20=28Larry=20Hao=20/=20=E9=83=9D=E5=8D=93?= =?UTF-8?q?=E8=BF=9C=29?= <107194248+hhh2210@users.noreply.github.com> Date: Sat, 22 Aug 2026 12:14:01 +0000 Subject: [PATCH] extension_host: Restore project LSP settings for extensions using old API versions (#63072) # 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 --- crates/extension_host/src/wasm_host/wit/since_v0_0_6.rs | 8 +++++++- crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_0_6.rs b/crates/extension_host/src/wasm_host/wit/since_v0_0_6.rs index cd731372276..8f81802ad2c 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_0_6.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_0_6.rs @@ -56,7 +56,13 @@ impl From 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(), } } } diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs index 83ba2ad3dfd..88bcfeff8ba 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs @@ -77,7 +77,13 @@ impl From 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(), } } }