Skip to content

Visual Studio Code, rebuilt in Rust

Rust

fix(windows): build webview and custom document uris from file paths

rokarturd6310ccc6189
diff --git a/native/crates/app/src/workbench/custom_documents.rs b/native/crates/app/src/workbench/custom_documents.rs
index 6e9ad689d4c..7e8a4cd5f09 100644
--- a/native/crates/app/src/workbench/custom_documents.rs
+++ b/native/crates/app/src/workbench/custom_documents.rs
@@ -242,7 +242,7 @@ impl Workbench {
let _ = sender.send(false);
return;
};
- let target_uri = Uri::new("file", "", &target.to_string_lossy(), "", "").map(|uri| uri.to_json()).unwrap_or_default();
+ let target_uri = Uri::file(&target.to_string_lossy()).to_json();
let saved = match editable {
true => {
let call = workbench.update(cx, |workbench, _| workbench.host.call_cancellable("ExtHostCustomEditors", "$onSaveAs", vec![resource.clone(), json!(view_type), target_uri.clone()]));
diff --git a/native/crates/app/src/workbench/walkthrough_part.rs b/native/crates/app/src/workbench/walkthrough_part.rs
index b92f767afbe..375e2d2db6b 100644
--- a/native/crates/app/src/workbench/walkthrough_part.rs
+++ b/native/crates/app/src/workbench/walkthrough_part.rs
@@ -76,7 +76,8 @@ impl Workbench {
/// module id as its query; `authority` first, as `uri_parts` keys it.
pub(super) fn playground_path(&self) -> PathBuf {
let query = json!({ "moduleId": MODULE_ID });
- PathBuf::from(format!("//vscode-app{}/out/{MODULE_ID}.md?{query}", self.app_root.display()))
+ let root = crate::uri::Uri::file(&self.app_root.to_string_lossy()).path;
+ PathBuf::from(format!("//vscode-app{root}/out/{MODULE_ID}.md?{query}"))
}
pub(super) fn is_playground(&self, editor: &OpenEditor) -> bool {
diff --git a/native/crates/app/src/workbench/welcome_page.rs b/native/crates/app/src/workbench/welcome_page.rs
index d04fbdf3e3e..32c5ad878fb 100644
--- a/native/crates/app/src/workbench/welcome_page.rs
+++ b/native/crates/app/src/workbench/welcome_page.rs
@@ -1539,6 +1539,7 @@ fn webview_uri(path: &str) -> String {
if path.starts_with("https://") {
return path.to_owned();
}
+ let path = crate::uri::Uri::file(path).path;
format!("https://file+.vscode-resource.vscode-cdn.net{}", path.replace('%', "%25").replace(' ', "%20").replace('#', "%23"))
}