Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unicode path handling on windows LSPs #2921

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

### Bug Fixes
- [#2779](https://github.com/lapce/lapce/pull/2779): Fix files detection on fresh git/VCS repository
- [#2920](https://github.com/lapce/lapce/pull/2920): Fix unicode path handling on windows LSPs

## 0.3.1

Expand Down
18 changes: 0 additions & 18 deletions lapce-app/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,24 +143,6 @@ impl CoreHandler for Proxy {
}
}

// Rust-analyzer returns paths in the form of "file:///<drive>:/...", which gets parsed into URL
// as "/<drive>://" which is then interpreted by PathBuf::new() as a UNIX-like path from root.
// This function strips the additional / from the beginning, if the first segment is a drive letter.
#[cfg(windows)]
pub fn path_from_url(url: &Url) -> PathBuf {
let path = url.path();
if let Some(path) = path.strip_prefix('/') {
if let Some((maybe_drive_letter, _)) = path.split_once(['/', '\\']) {
let b = maybe_drive_letter.as_bytes();
if b.len() == 2 && b[0].is_ascii_alphabetic() && b[1] == b':' {
return PathBuf::from(path);
}
}
}
PathBuf::from(path)
}

#[cfg(not(windows))]
pub fn path_from_url(url: &Url) -> PathBuf {
url.to_file_path()
.unwrap_or_else(|_| PathBuf::from(url.path()))
Expand Down