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

@ -60,14 +60,15 @@ impl StatefulRequest for RenameRequest {
// todo: rename in untitled files
let old_path = ctx.path_for_id(def_fid).ok()?.to_err().ok()?;
let new_path = Path::new(new_path_str.as_str());
let rename_loc = Path::new(ref_path_str.as_str());
let diff = pathdiff::diff_paths(Path::new(&new_path_str), rename_loc)?;
let diff = tinymist_std::path::diff(new_path, rename_loc)?;
if diff.is_absolute() {
log::info!("bad rename: absolute path, base: {rename_loc:?}, new: {new_path_str}, diff: {diff:?}");
log::info!("bad rename: absolute path, base: {rename_loc:?}, new: {new_path:?}, diff: {diff:?}");
return None;
}
let new_path = old_path.join(&diff);
let new_path = old_path.join(&diff).clean();
let old_uri = path_to_url(&old_path).ok()?;
let new_uri = path_to_url(&new_path).ok()?;