Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
languages: Fix panic in python lsp adapters assuming settings shape (#38309)
Lukas Wirth28800c2a3b55
diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rsindex d989f4d6dc2..e0273250c91 100644--- a/crates/languages/src/python.rs+++ b/crates/languages/src/python.rs@@ -461,7 +461,7 @@ impl LspAdapter for PyrightLspAdapter {pet_core::python_environment::PythonEnvironment,>(toolchain.as_json.clone()){- if user_settings.is_null() {+ if !user_settings.is_object() {user_settings = Value::Object(serde_json::Map::default());}let object = user_settings.as_object_mut().unwrap();@@ -492,9 +492,13 @@ impl LspAdapter for PyrightLspAdapter {// Get or create the python sectionlet python = object.entry("python")- .or_insert(Value::Object(serde_json::Map::default()))- .as_object_mut()- .unwrap();+ .and_modify(|v| {+ if !v.is_object() {+ *v = Value::Object(serde_json::Map::default());+ }+ })+ .or_insert(Value::Object(serde_json::Map::default()));+ let python = python.as_object_mut().unwrap();// Set both pythonPath and defaultInterpreterPath for compatibilitypython.insert(@@ -1465,7 +1469,7 @@ impl LspAdapter for PyLspAdapter {// If user did not explicitly modify their python venv, use one from picker.if let Some(toolchain) = toolchain {- if user_settings.is_null() {+ if !user_settings.is_object() {user_settings = Value::Object(serde_json::Map::default());}let object = user_settings.as_object_mut().unwrap();@@ -1787,7 +1791,7 @@ impl LspAdapter for BasedPyrightLspAdapter {pet_core::python_environment::PythonEnvironment,>(toolchain.as_json.clone()){- if user_settings.is_null() {+ if !user_settings.is_object() {user_settings = Value::Object(serde_json::Map::default());}let object = user_settings.as_object_mut().unwrap();