fix: correct rename on unix platforms caused by pathdiff#8 (#1587)

* fix: correct rename on unix platforms caused by pathdiff#8

* fix: ensure all calls to pathdiff

* fix: names

* fix: file path on windows
This commit is contained in:
Myriad-Dreamin 2025-03-26 12:46:33 +08:00 committed by GitHub
parent c102ace9ab
commit e4a4fc568f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 44 additions and 28 deletions

View file

@ -465,10 +465,12 @@ pub(crate) fn file_path(uri: &str) -> String {
} else {
PathBuf::from("/root")
};
let uri = uri.replace("file://", "");
let abs_path = Path::new(&uri).strip_prefix(root).map(|s| s.as_os_str());
let rel_path = abs_path.unwrap_or_else(|_| Path::new(&uri).file_name().unwrap());
unix_slash(Path::new(rel_path.to_str().unwrap()))
let uri = lsp_types::Url::parse(uri).unwrap().to_file_path().unwrap();
let abs_path = Path::new(&uri).strip_prefix(root).map(|p| p.to_owned());
let rel_path =
abs_path.unwrap_or_else(|_| Path::new("-").join(Path::new(&uri).iter().last().unwrap()));
unix_slash(&rel_path)
}
pub struct HashRepr<T>(pub T);