lsp: Always report innermost workspace_folders (#36407)

Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Piotr Osiewicz 2025-08-18 13:48:21 +02:00 committed by GitHub
parent 57198f33c4
commit 5225844c9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 33 deletions

View file

@ -283,15 +283,6 @@ impl CachedLspAdapter {
} }
} }
/// Determines what gets sent out as a workspace folders content
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum WorkspaceFoldersContent {
/// Send out a single entry with the root of the workspace.
WorktreeRoot,
/// Send out a list of subproject roots.
SubprojectRoots,
}
/// [`LspAdapterDelegate`] allows [`LspAdapter]` implementations to interface with the application /// [`LspAdapterDelegate`] allows [`LspAdapter]` implementations to interface with the application
// e.g. to display a notification or fetch data from the web. // e.g. to display a notification or fetch data from the web.
#[async_trait] #[async_trait]
@ -580,13 +571,6 @@ pub trait LspAdapter: 'static + Send + Sync {
Ok(original) Ok(original)
} }
/// Determines whether a language server supports workspace folders.
///
/// And does not trip over itself in the process.
fn workspace_folders_content(&self) -> WorkspaceFoldersContent {
WorkspaceFoldersContent::SubprojectRoots
}
/// Method only implemented by the default JSON language server adapter. /// Method only implemented by the default JSON language server adapter.
/// Used to provide dynamic reloading of the JSON schemas used to /// Used to provide dynamic reloading of the JSON schemas used to
/// provide autocompletion and diagnostics in Zed setting and keybind /// provide autocompletion and diagnostics in Zed setting and keybind

View file

@ -4,13 +4,13 @@ use async_trait::async_trait;
use collections::HashMap; use collections::HashMap;
use gpui::{App, Task}; use gpui::{App, Task};
use gpui::{AsyncApp, SharedString}; use gpui::{AsyncApp, SharedString};
use language::Toolchain;
use language::ToolchainList; use language::ToolchainList;
use language::ToolchainLister; use language::ToolchainLister;
use language::language_settings::language_settings; use language::language_settings::language_settings;
use language::{ContextLocation, LanguageToolchainStore}; use language::{ContextLocation, LanguageToolchainStore};
use language::{ContextProvider, LspAdapter, LspAdapterDelegate}; use language::{ContextProvider, LspAdapter, LspAdapterDelegate};
use language::{LanguageName, ManifestName, ManifestProvider, ManifestQuery}; use language::{LanguageName, ManifestName, ManifestProvider, ManifestQuery};
use language::{Toolchain, WorkspaceFoldersContent};
use lsp::LanguageServerBinary; use lsp::LanguageServerBinary;
use lsp::LanguageServerName; use lsp::LanguageServerName;
use node_runtime::{NodeRuntime, VersionStrategy}; use node_runtime::{NodeRuntime, VersionStrategy};
@ -389,10 +389,6 @@ impl LspAdapter for PythonLspAdapter {
user_settings user_settings
}) })
} }
fn workspace_folders_content(&self) -> WorkspaceFoldersContent {
WorkspaceFoldersContent::WorktreeRoot
}
} }
async fn get_cached_server_binary( async fn get_cached_server_binary(
@ -1257,9 +1253,6 @@ impl LspAdapter for PyLspAdapter {
user_settings user_settings
}) })
} }
fn workspace_folders_content(&self) -> WorkspaceFoldersContent {
WorkspaceFoldersContent::WorktreeRoot
}
} }
pub(crate) struct BasedPyrightLspAdapter { pub(crate) struct BasedPyrightLspAdapter {
@ -1577,10 +1570,6 @@ impl LspAdapter for BasedPyrightLspAdapter {
user_settings user_settings
}) })
} }
fn workspace_folders_content(&self) -> WorkspaceFoldersContent {
WorkspaceFoldersContent::WorktreeRoot
}
} }
#[cfg(test)] #[cfg(test)]

View file

@ -57,7 +57,7 @@ use language::{
DiagnosticEntry, DiagnosticSet, DiagnosticSourceKind, Diff, File as _, Language, LanguageName, DiagnosticEntry, DiagnosticSet, DiagnosticSourceKind, Diff, File as _, Language, LanguageName,
LanguageRegistry, LocalFile, LspAdapter, LspAdapterDelegate, ManifestDelegate, ManifestName, LanguageRegistry, LocalFile, LspAdapter, LspAdapterDelegate, ManifestDelegate, ManifestName,
Patch, PointUtf16, TextBufferSnapshot, ToOffset, ToPointUtf16, Toolchain, Transaction, Patch, PointUtf16, TextBufferSnapshot, ToOffset, ToPointUtf16, Toolchain, Transaction,
Unclipped, WorkspaceFoldersContent, Unclipped,
language_settings::{ language_settings::{
FormatOnSave, Formatter, LanguageSettings, SelectedFormatter, language_settings, FormatOnSave, Formatter, LanguageSettings, SelectedFormatter, language_settings,
}, },
@ -344,10 +344,7 @@ impl LocalLspStore {
binary, binary,
&root_path, &root_path,
code_action_kinds, code_action_kinds,
Some(pending_workspace_folders).filter(|_| { Some(pending_workspace_folders),
adapter.adapter.workspace_folders_content()
== WorkspaceFoldersContent::SubprojectRoots
}),
cx, cx,
) )
} }