Skip to content

Commit

Permalink
Workaround UNC path fs::canonicalize return
Browse files Browse the repository at this point in the history
Reported in rust-lang#838
Also see rust-lang/rust#42869
  • Loading branch information
alexheretic committed May 28, 2018
1 parent 453f5e4 commit ea18376
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,17 @@ fn initialize(root_path: String) -> Request<server::InitializeRequest> {
}

fn url(file_name: &str) -> Url {
let path = Path::new(file_name)
let canonical = Path::new(file_name)
.canonicalize()
.expect("Could not canonicalize file name");
Url::parse(&format!("file://{}", path.to_str().unwrap())).expect("Bad file name")
let mut path = canonical.to_str().unwrap();

// workaround for UNC path see https://github.com/rust-lang/rust/issues/42869
if path.starts_with(r"\\?\") {
path = &path[r"\\?\".len()..];
}

Url::parse(&format!("file://{}", path)).expect("Bad file name")
}

fn next_id() -> usize {
Expand Down

0 comments on commit ea18376

Please sign in to comment.