extension_host: Use the more permissive RelPath constructor for paths from extensions (#38965)

Cole Miller and Jakub Konka created

Closes #38922 

Release Notes:

- N/A

---------

Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>

Change summary

crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs | 15 +++++--
crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs | 20 +++++++---
2 files changed, 23 insertions(+), 12 deletions(-)

Detailed changes

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" => {

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" => {