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.  # 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>
This commit is contained in:
1 parent
fd82517a11
commit
7eec89207c
2 files changed
+14
-2
No files matched your search
@@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user