fix as suggestion.
This commit is contained in:
parent
1b004dcf88
commit
d877390882
@ -433,27 +433,23 @@ pub(crate) fn handle_will_rename_files(
|
||||
match (from_path.parent(), to_path.parent()) {
|
||||
(Some(p1), Some(p2)) if p1 == p2 => {
|
||||
if from_path.is_dir() {
|
||||
// This is a quick implement, try to use will_rename_file code.
|
||||
// imitate change the older_folder/mod.rs to older_folder/new_folder.rs
|
||||
|
||||
// add '/' to end of url -- from `file://path/to/folder` to `file://path/to/folder/`
|
||||
let mut old_folder_name = from_path.file_stem()?.to_str()?.to_string();
|
||||
old_folder_name.push('/');
|
||||
let from_with_trailing_slash = from.join(&old_folder_name).ok()?;
|
||||
|
||||
let imitate_from_url = from_with_trailing_slash.join("mod.rs").ok()?;
|
||||
let imite_new_file_name = to_path.file_name()?.to_str()?;
|
||||
let new_file_name = to_path.file_name()?.to_str()?;
|
||||
Some((
|
||||
snap.url_to_file_id(&imitate_from_url).ok()?,
|
||||
imite_new_file_name.to_string(),
|
||||
new_file_name.to_string(),
|
||||
))
|
||||
} else {
|
||||
let old_name = from_path.file_stem()?.to_str()?;
|
||||
let new_name = to_path.file_stem()?.to_str()?;
|
||||
if old_name != "mod" && new_name != "mod" {
|
||||
Some((snap.url_to_file_id(&from).ok()?, new_name.to_string()))
|
||||
} else {
|
||||
None
|
||||
match(old_name,new_name){
|
||||
("mod","mod") =>Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())),
|
||||
_=>None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user