python: Fix user settings not getting passed on for Ty (#39174)

Closes #39144

Release Notes:

- python: Fixed user settings not being respected with Ty language
server.
This commit is contained in:
Piotr Osiewicz 2025-09-30 10:19:23 +02:00 committed by GitHub
parent 6af385235d
commit bf9dd6bbef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -154,11 +154,16 @@ impl LspAdapter for TyLspAdapter {
async fn workspace_configuration(
self: Arc<Self>,
_: &Arc<dyn LspAdapterDelegate>,
delegate: &Arc<dyn LspAdapterDelegate>,
toolchain: Option<Toolchain>,
_cx: &mut AsyncApp,
cx: &mut AsyncApp,
) -> Result<Value> {
let mut ret = json!({});
let mut ret = cx
.update(|cx| {
language_server_settings(delegate.as_ref(), &self.name(), cx)
.and_then(|s| s.settings.clone())
})?
.unwrap_or_else(|| json!({}));
if let Some(toolchain) = toolchain.and_then(|toolchain| {
serde_json::from_value::<PythonEnvironment>(toolchain.as_json).ok()
}) {
@ -171,10 +176,9 @@ impl LspAdapter for TyLspAdapter {
"sysPrefix": sys_prefix
}
});
ret.as_object_mut()?.insert(
"pythonExtension".into(),
json!({ "activeEnvironment": environment }),
);
ret.as_object_mut()?
.entry("pythonExtension")
.or_insert_with(|| json!({ "activeEnvironment": environment }));
Some(())
});
}
@ -463,7 +467,6 @@ impl LspAdapter for PyrightLspAdapter {
async fn workspace_configuration(
self: Arc<Self>,
adapter: &Arc<dyn LspAdapterDelegate>,
toolchain: Option<Toolchain>,
cx: &mut AsyncApp,