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