Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
extension_host: Use the more permissive RelPath constructor for paths from extensions (#38965)
Cole Miller687e22b4c3fd
diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rsindex 73207b30366..26347ec4426 100644--- a/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs+++ b/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs@@ -16,6 +16,7 @@ use std::{path::{Path, PathBuf},sync::{Arc, OnceLock},};+use util::paths::PathStyle;use util::rel_path::RelPath;use util::{archive::extract_zip, fs::make_file_executable, maybe};use wasmtime::component::{Linker, Resource};@@ -422,12 +423,16 @@ impl ExtensionImports for WasmState {) -> wasmtime::Result<Result<String, String>> {self.on_main_thread(|cx| {async move {- let location = location.as_ref().and_then(|location| {- Some(::settings::SettingsLocation {- worktree_id: WorktreeId::from_proto(location.worktree_id),- path: RelPath::unix(&location.path).ok()?,- })+ let path = location.as_ref().and_then(|location| {+ RelPath::new(Path::new(&location.path), PathStyle::Posix).ok()});+ let location = path+ .as_ref()+ .zip(location.as_ref())+ .map(|(path, location)| ::settings::SettingsLocation {+ worktree_id: WorktreeId::from_proto(location.worktree_id),+ path,+ });cx.update(|cx| match category.as_str() {"language" => {diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rsindex 861f73f4a4e..b43ea0a6332 100644--- a/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs+++ b/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs@@ -31,7 +31,9 @@ use std::{};use task::{SpawnInTerminal, ZedDebugConfig};use url::Url;-use util::{archive::extract_zip, fs::make_file_executable, maybe, rel_path::RelPath};+use util::{+ archive::extract_zip, fs::make_file_executable, maybe, paths::PathStyle, rel_path::RelPath,+};use wasmtime::component::{Linker, Resource};pub const MIN_VERSION: SemanticVersion = SemanticVersion::new(0, 6, 0);@@ -564,7 +566,7 @@ impl HostWorktree for WasmState {) -> wasmtime::Result<Result<String, String>> {let delegate = self.table.get(&delegate)?;Ok(delegate- .read_text_file(RelPath::unix(&path)?)+ .read_text_file(&RelPath::new(Path::new(&path), PathStyle::Posix)?).await.map_err(|error| error.to_string()))}@@ -914,12 +916,16 @@ impl ExtensionImports for WasmState {) -> wasmtime::Result<Result<String, String>> {self.on_main_thread(|cx| {async move {- let location = location.as_ref().and_then(|location| {- Some(::settings::SettingsLocation {- worktree_id: WorktreeId::from_proto(location.worktree_id),- path: RelPath::unix(&location.path).ok()?,- })+ let path = location.as_ref().and_then(|location| {+ RelPath::new(Path::new(&location.path), PathStyle::Posix).ok()});+ let location = path+ .as_ref()+ .zip(location.as_ref())+ .map(|(path, location)| ::settings::SettingsLocation {+ worktree_id: WorktreeId::from_proto(location.worktree_id),+ path,+ });cx.update(|cx| match category.as_str() {"language" => {