lsp/python: Temporarily report just a singular workspace folder instead of all of the roots (#35243)

Temporarily fixes #29133

Co-authored-by: Cole <cole@zed.dev>

Release Notes:

- python: Zed now reports a slightly different set of workspace folders
for Python projects to work around quirks in handling of multi-lsp
projects with virtual environment. This behavior will be revisited in a
near future.

Co-authored-by: Cole <cole@zed.dev>
This commit is contained in:
Piotr Osiewicz 2025-07-29 02:10:32 +02:00 committed by GitHub
parent d2ef287791
commit e5269212ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 76 additions and 27 deletions

View file

@ -46,6 +46,7 @@ use language::{
DiagnosticEntry, DiagnosticSet, DiagnosticSourceKind, Diff, File as _, Language, LanguageName,
LanguageRegistry, LanguageToolchainStore, LocalFile, LspAdapter, LspAdapterDelegate, Patch,
PointUtf16, TextBufferSnapshot, ToOffset, ToPointUtf16, Transaction, Unclipped,
WorkspaceFoldersContent,
language_settings::{
FormatOnSave, Formatter, LanguageSettings, SelectedFormatter, language_settings,
},
@ -217,6 +218,7 @@ impl LocalLspStore {
let binary = self.get_language_server_binary(adapter.clone(), delegate.clone(), true, cx);
let pending_workspace_folders: Arc<Mutex<BTreeSet<Url>>> = Default::default();
let pending_server = cx.spawn({
let adapter = adapter.clone();
let server_name = adapter.name.clone();
@ -242,14 +244,18 @@ impl LocalLspStore {
return Ok(server);
}
let code_action_kinds = adapter.code_action_kinds();
lsp::LanguageServer::new(
stderr_capture,
server_id,
server_name,
binary,
&root_path,
adapter.code_action_kinds(),
pending_workspace_folders,
code_action_kinds,
Some(pending_workspace_folders).filter(|_| {
adapter.adapter.workspace_folders_content()
== WorkspaceFoldersContent::SubprojectRoots
}),
cx,
)
}
@ -575,8 +581,7 @@ impl LocalLspStore {
};
let root = server.workspace_folders();
Ok(Some(
root.iter()
.cloned()
root.into_iter()
.map(|uri| WorkspaceFolder {
uri,
name: Default::default(),