Skip to content

Commit 778cb03

Browse files
committed
fix: windows root path detection
1 parent 9b14d74 commit 778cb03

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/config/workspace.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::{
22
collections::{HashMap, HashSet},
3+
env,
34
path::{Path, PathBuf},
45
};
56

@@ -106,9 +107,20 @@ impl WorkspaceProtoConfigs {
106107

107108
pub fn no_workspace_mode(&mut self) {
108109
let wr = ProtolsConfig::default();
109-
let uri = match Url::from_file_path("/") {
110+
let rp = if cfg!(target_os = "windows") {
111+
let mut d = String::from("C");
112+
if let Ok(cdir) = env::current_dir() {
113+
if let Some(drive) = cdir.components().next() {
114+
d = drive.as_os_str().to_string_lossy().to_string()
115+
}
116+
}
117+
format!("{d}://")
118+
} else {
119+
String::from("/")
120+
};
121+
let uri = match Url::from_file_path(&rp) {
110122
Err(err) => {
111-
tracing::error!(?err, "failed to convert path: '/' to Url");
123+
tracing::error!(?err, "failed to convert path: {rp} to Url");
112124
return;
113125
}
114126
Ok(uri) => uri,

0 commit comments

Comments
 (0)