Skip to content

Commit 70e3eb7

Browse files
committed
Fix uri to Windows file path.
Close #229.
1 parent 801bf70 commit 70e3eb7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/languageclient.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,17 @@ impl ILanguageClient for Arc<Mutex<State>> {
14721472
return Ok(());
14731473
}
14741474

1475-
let filename = params.uri.path().to_owned();
1475+
let mut filename = params
1476+
.uri
1477+
.to_file_path()
1478+
.map_err(|_| format_err!("Failed to convert uri to file path"))?
1479+
.to_str()
1480+
.ok_or_else(|| format_err!("Failed to convert PathBuf to str"))?
1481+
.to_owned();
1482+
// Remove first '/' in case of '/C:/blabla'.
1483+
if filename.chars().nth(0) == Some('/') && filename.chars().nth(2) == Some(':') {
1484+
filename.remove(0);
1485+
}
14761486
self.update(|state| {
14771487
state
14781488
.diagnostics

0 commit comments

Comments
 (0)